From 5d9fe507f14a34cdde8bb9a6710a7d46bd61e530 Mon Sep 17 00:00:00 2001 From: Fedor Korotkov Date: Fri, 5 Jun 2026 10:12:53 -0700 Subject: [PATCH] Migrate CI to GitHub Actions --- .cirrus.yml | 91 --------------------------- .github/workflows/ci.yml | 99 ++++++++++++++++++++++++++++++ .github/workflows/release.yml | 47 ++++++++++++++ .golangci.yml | 26 ++++---- .goreleaser.yml | 27 +------- packaging/postinstall.sh | 15 ----- packaging/postremove.sh | 13 ---- packaging/preremove.sh | 14 ----- packaging/tart-guest-agent.service | 10 --- 9 files changed, 160 insertions(+), 182 deletions(-) delete mode 100644 .cirrus.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml delete mode 100644 packaging/postinstall.sh delete mode 100644 packaging/postremove.sh delete mode 100644 packaging/preremove.sh delete mode 100644 packaging/tart-guest-agent.service diff --git a/.cirrus.yml b/.cirrus.yml deleted file mode 100644 index b07270d..0000000 --- a/.cirrus.yml +++ /dev/null @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7bf6e52 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,99 @@ +name: CI + +on: + merge_group: + pull_request: + push: + branches: + - main + workflow_dispatch: + +permissions: + contents: read + pull-requests: read + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-go@v6 + with: + go-version-file: go.mod + cache: true + - name: Install system dependencies + run: sudo apt-get update && sudo apt-get install --yes libx11-dev + - uses: golangci/golangci-lint-action@v9 + with: + version: v2.12.0 + only-new-issues: true + + test-linux: + name: Test (Linux) + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-go@v6 + with: + go-version-file: go.mod + cache: true + - name: Install system dependencies + run: sudo apt-get update && sudo apt-get install --yes libx11-dev + - name: Run tests + run: go test -v ./... + + test-macos: + name: Test (macOS) + runs-on: ghcr.io/cirruslabs/macos-runner:sequoia + timeout-minutes: 30 + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-go@v6 + with: + go-version-file: go.mod + cache: true + - name: Run tests + run: go test -v ./... + + generated-code: + name: Check generated code + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-go@v6 + with: + go-version-file: go.mod + cache: true + - name: Install Buf + run: go install github.com/bufbuild/buf/cmd/buf@v1.50.0 + - name: Generate code + run: buf generate + - name: Check for changes + run: git diff --exit-code + + buf-push: + name: Push Buf module + if: github.event_name == 'push' && github.repository_owner == 'openai' + needs: generated-code + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + - uses: actions/setup-go@v6 + with: + go-version-file: go.mod + cache: true + - 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 + env: + BUF_TOKEN: ${{ secrets.BUF_TOKEN }} + - name: Push module + run: buf push --git-metadata diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0e6c24e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,47 @@ +name: Release + +on: + push: + tags: + - "*" + workflow_dispatch: + +permissions: + contents: write + +jobs: + release: + name: ${{ github.ref_type == 'tag' && 'Release' || 'Release (Dry Run)' }} + runs-on: ghcr.io/cirruslabs/macos-runner:sequoia + timeout-minutes: 60 + env: + GITHUB_TOKEN: ${{ secrets.GH_PAT }} + GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + - uses: actions/setup-go@v6 + with: + go-version-file: go.mod + cache: true + - name: Release + if: github.ref_type == 'tag' + uses: goreleaser/goreleaser-action@v7 + with: + distribution: goreleaser-pro + version: "~> v2" + args: release --clean + - name: Release dry run + if: github.ref_type != 'tag' + uses: goreleaser/goreleaser-action@v7 + with: + distribution: goreleaser-pro + version: "~> v2" + args: release --skip=publish --snapshot --clean + - name: Upload dry-run artifacts + if: github.ref_type != 'tag' + uses: actions/upload-artifact@v6 + with: + name: tart-guest-agent-snapshot + path: dist/** diff --git a/.golangci.yml b/.golangci.yml index d69190a..385b1c1 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,21 +1,21 @@ -version: 2 +version: "2" run: timeout: 5m -linters-settings: - # Even in Rust you can get away with partial matching, - # so make sure that the linter respects the programmer's - # intent expressed in the form of "default" case. - exhaustive: - default-signifies-exhaustive: true - - gosec: - excludes: - - G115 - linters: - enable-all: true + default: all + + settings: + # Even in Rust you can get away with partial matching, + # so make sure that the linter respects the programmer's + # intent expressed in the form of "default" case. + exhaustive: + default-signifies-exhaustive: true + + gosec: + excludes: + - G115 disable: # We don't have high-performance requirements at this moment, so sacrificing diff --git a/.goreleaser.yml b/.goreleaser.yml index fc2e1d3..d340515 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -53,32 +53,7 @@ brews: repository: owner: cirruslabs name: homebrew-cli - homepage: https://github.com/cirruslabs/tart-guest-agent + homepage: https://github.com/openai/tart-guest-agent license: FSL-1.1-Apache-2.0 description: Guest agent for Tart VMs skip_upload: auto - -nfpms: - - package_name: "{{ .ProjectName }}" - vendor: Cirrus Labs, Inc. - homepage: https://github.com/cirruslabs/tart-guest-agent - maintainer: support@cirruslabs.org - description: Guest agent for Tart VMs - section: misc - formats: - - apk - - deb - - rpm - contents: - - src: packaging/tart-guest-agent.service - dst: /etc/systemd/system/tart-guest-agent.service - file_info: - mode: 0644 - - scripts: - postinstall: packaging/postinstall.sh - preremove: packaging/preremove.sh - postremove: packaging/postremove.sh - -furies: - - account: cirruslabs diff --git a/packaging/postinstall.sh b/packaging/postinstall.sh deleted file mode 100644 index f0bbd15..0000000 --- a/packaging/postinstall.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -# Set shell options to enable fail-fast behavior -# -# * -e: fail the script when an error occurs or command fails -# * -u: fail the script when attempting to reference unset parameters -# * -o pipefail: by default an exit status of a pipeline is that of its -# last command, this fails the pipe early if an error in -# any of its commands occurs -# -set -euo pipefail - -systemctl daemon-reload -systemctl enable tart-guest-agent.service -systemctl start tart-guest-agent.service diff --git a/packaging/postremove.sh b/packaging/postremove.sh deleted file mode 100644 index 00f48a2..0000000 --- a/packaging/postremove.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -# Set shell options to enable fail-fast behavior -# -# * -e: fail the script when an error occurs or command fails -# * -u: fail the script when attempting to reference unset parameters -# * -o pipefail: by default an exit status of a pipeline is that of its -# last command, this fails the pipe early if an error in -# any of its commands occurs -# -set -euo pipefail - -systemctl daemon-reload diff --git a/packaging/preremove.sh b/packaging/preremove.sh deleted file mode 100644 index 22c08fb..0000000 --- a/packaging/preremove.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# Set shell options to enable fail-fast behavior -# -# * -e: fail the script when an error occurs or command fails -# * -u: fail the script when attempting to reference unset parameters -# * -o pipefail: by default an exit status of a pipeline is that of its -# last command, this fails the pipe early if an error in -# any of its commands occurs -# -set -euo pipefail - -systemctl stop tart-guest-agent.service -systemctl disable tart-guest-agent.service diff --git a/packaging/tart-guest-agent.service b/packaging/tart-guest-agent.service deleted file mode 100644 index e3057e7..0000000 --- a/packaging/tart-guest-agent.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=Guest agent for Tart VMs - -[Service] -Type=simple -User=admin -ExecStart=tart-guest-agent --run-rpc - -[Install] -WantedBy=multi-user.target