Migrate CI to GitHub Actions

This commit is contained in:
Fedor Korotkov
2026-06-03 14:02:20 -07:00
parent 87b0e2d9c8
commit a1ac589a72
2 changed files with 158 additions and 91 deletions
-91
View File
@@ -1,91 +0,0 @@
task:
name: Lint
container:
image: golangci/golangci-lint:latest
cpu: 2
memory: 4096
prepare_script:
- apt-get update
- apt-get install -y libx11-dev
lint_script:
- golangci-lint run -v --output.json.path golangci.json
always:
report_artifacts:
path: golangci.json
type: text/json
format: golangci
task:
name: Test (Linux)
alias: Tests
container:
image: golang:latest
prepare_script:
- apt-get update
- apt-get install -y libx11-dev
test_script: go test -v ./...
task:
name: Test (macOS)
alias: Tests
macos_instance:
image: ghcr.io/cirruslabs/macos-runner:sequoia
prepare_script: brew install go
test_script: go test -v ./...
task:
name: Check for lacking "buf generate" invocation
container:
image: golang:latest
install_buf_script: go install github.com/bufbuild/buf/cmd/buf@v1.50.0
generate_script: buf generate
check_script: git diff --exit-code
task:
only_if: $CIRRUS_BRANCH != '' && $CIRRUS_PR == '' && $CIRRUS_REPO_OWNER == 'cirruslabs'
name: buf push
container:
image: bufbuild/buf
login_script: echo "$BUF_TOKEN" | buf registry login --token-stdin
push_script: buf push --git-metadata
env:
BUF_TOKEN: ENCRYPTED[!8ee7eb2504cc84b08d4a7c0dacbe103640b1feaa26d06f0df010784e872d39e65a0cdea3fc7c09b065a917a77113b96b!]
task:
name: Release (Dry Run)
only_if: $CIRRUS_TAG == ''
macos_instance:
image: ghcr.io/cirruslabs/macos-runner:sequoia
depends_on:
- Lint
- Tests
install_script:
- brew install go
- brew install --cask goreleaser/tap/goreleaser-pro
release_script: goreleaser release --clean --snapshot
goreleaser_artifacts:
path: "dist/**"
task:
name: Release
only_if: $CIRRUS_TAG != ''
macos_instance:
image: ghcr.io/cirruslabs/macos-runner:sequoia
depends_on:
- Lint
- Tests
env:
GITHUB_TOKEN: ENCRYPTED[!98ace8259c6024da912c14d5a3c5c6aac186890a8d4819fad78f3e0c41a4e0cd3a2537dd6e91493952fb056fa434be7c!]
FURY_TOKEN: ENCRYPTED[!97fe4497d9aca60a3d64904883b81e21f19706c6aedda625c97f62f67ec46b8efa74c55699956158bbf0a23726e7d9f6!]
GORELEASER_KEY: ENCRYPTED[!9b80b6ef684ceaf40edd4c7af93014ee156c8aba7e6e5795f41c482729887b5c31f36b651491d790f1f668670888d9fd!]
install_script:
- brew install go
- brew install --cask goreleaser/tap/goreleaser-pro
release_script: goreleaser
+158
View File
@@ -0,0 +1,158 @@
name: CI
on:
pull_request:
push:
branches:
- main
tags:
- '*'
workflow_dispatch:
permissions:
contents: read
jobs:
lint:
name: Lint
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v5
with:
go-version: stable
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libx11-dev
- name: Install golangci-lint
run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
- name: Lint
run: golangci-lint run -v --output.json.path golangci.json
- name: Upload golangci report
if: always()
uses: actions/upload-artifact@v4
with:
name: golangci-report
path: golangci.json
if-no-files-found: ignore
test_linux:
name: Test (Linux)
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v5
with:
go-version: stable
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libx11-dev
- name: Test
run: go test -v ./...
test_macos:
name: Test (macOS)
runs-on: macos-15
timeout-minutes: 20
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v5
with:
go-version: stable
- name: Test
run: go test -v ./...
buf_generate:
name: Check for lacking buf generate invocation
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v5
with:
go-version: stable
- name: Install buf
run: go install github.com/bufbuild/buf/cmd/buf@v1.50.0
- name: Generate
run: buf generate
- name: Check generated files
run: git diff --exit-code
buf_push:
name: buf push
if: github.event_name == 'push' && github.ref_type == 'branch' && github.repository == 'cirruslabs/tart-guest-agent'
needs:
- buf_generate
runs-on: ubuntu-24.04
timeout-minutes: 15
env:
BUF_TOKEN: ${{ secrets.BUF_TOKEN }}
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v5
with:
go-version: stable
- name: Install buf
run: go install github.com/bufbuild/buf/cmd/buf@v1.50.0
- name: Log in to buf
run: echo "$BUF_TOKEN" | buf registry login --token-stdin
- name: Push
run: buf push --git-metadata
release_dry_run:
name: Release (Dry Run)
if: github.event_name != 'pull_request' && github.ref_type != 'tag'
needs:
- lint
- test_linux
- test_macos
runs-on: macos-15
timeout-minutes: 45
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: stable
- name: Install GoReleaser
run: brew install --cask goreleaser/tap/goreleaser-pro
- name: Build snapshot
run: goreleaser release --clean --snapshot
- name: Upload dist
uses: actions/upload-artifact@v4
with:
name: dist-dry-run
path: dist/**
if-no-files-found: ignore
release:
name: Release
if: github.ref_type == 'tag'
needs:
- lint
- test_linux
- test_macos
runs-on: macos-15
timeout-minutes: 45
permissions:
contents: write
env:
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: stable
- name: Install GoReleaser
run: brew install --cask goreleaser/tap/goreleaser-pro
- name: Release
run: goreleaser