diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index fd866f0a..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,128 +0,0 @@ -name: Continuous Integration - -on: - push: - branches: - - main - pull_request: - merge_group: - types: - - checks_requested - -jobs: - lint: - name: Lint - runs-on: ubuntu-latest - permissions: - pull-requests: read - checks: write - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: '1.21' - - name: golangci-lint - uses: golangci/golangci-lint-action@v6 - with: - version: v1.59 - only-new-issues: true - - name: Tidy go.mod - run: go mod tidy - - name: Check Tidy go.mod - run: | - git diff --exit-code || { echo "##[error] go.mod is not tidy, run 'go mod tidy' and commit the changes."; exit 1; } - - test: - name: Test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: '1.21' - - name: Build - run: make build - - name: Test - run: make test/cover - - name: Upload coverage to Codecov - # Commit SHA corresponds to version v4.4.1 - # See: https://github.com/codecov/codecov-action/releases/tag/v4.4.1 - uses: codecov/codecov-action@125fc84a9a348dbcf27191600683ec096ec9021c - # Don't run coverage on merge queue CI to avoid duplicating reports to codecov. - # Otherwise base coverage from main branch does not render properly. - # - # See: https://github.com/matplotlib/napari-matplotlib/issues/155#issuecomment-1589377119 - if: github.event_name != 'merge_group' - with: - files: coverage.txt - token: ${{ secrets.CODECOV_TOKEN }} - fail_ci_if_error: false - - fuzz: - name: Fuzz - runs-on: ubuntu-latest - needs: - - test # Do not bother running the fuzz tests if tests fail - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: '1.21' - - name: Fuzz - env: - FUZZTIME: 30s - run: make fuzz - - name: Upload fuzz failure seed corpus as run artifact - if: failure() - uses: actions/upload-artifact@v4 - id: testdata-upload - with: - name: testdata - path: '**/testdata/fuzz' - - name: Output message - if: failure() - shell: bash - run: | - echo -e 'Fuzz test failed on commit https://github.com/${{ github.repository }}/commit/${{ github.event.pull_request.head.sha }}. To troubleshoot locally, use the GitHub CLI to download the seed corpus by running:\n $ gh run download ${ github.run_id } -n testdata\nAlternatively, download from:\n ${{ steps.testdata-upload.outputs.artifact-url }}' - - name: Post PR comment - uses: actions/github-script@v7 - if: failure() && github.event_name == 'pull_request' - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: 'Fuzz test failed on commit ${{ github.event.pull_request.head.sha }}. To troubleshoot locally, download the seed corpus using [GitHub CLI](https://cli.github.com) by running:\n```shell\ngh run download ${{ github.run_id }} -n testdata\n```\nAlternatively, download directly from [here](${{ steps.testdata-upload.outputs.artifact-url }}).' - }) - - test-race: - name: Test With Race Detector - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v4 - with: - go-version: '1.21' - - name: Test with race detection - env: - # Run tests with race detector, excluding fuzz tests. - # Fuzz tests are excluded because they will otherwise - # take too long to complete. - GOTEST_ARGS: -race -run='^[^Fuzz]' -short -timeout=20m - run: make test - - generate: - name: Generate - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: '1.21' - - name: Generate - run: make generate - - name: Check for changes - run: | - git diff --exit-code || { echo "##[error] Generated code differs from repository content, run 'make generate' and commit the changes."; exit 1; } diff --git a/.github/workflows/go-check.yml b/.github/workflows/go-check.yml index 232775da..08bf17ee 100644 --- a/.github/workflows/go-check.yml +++ b/.github/workflows/go-check.yml @@ -5,6 +5,7 @@ on: push: branches: ["main"] workflow_dispatch: + merge_group: permissions: contents: read diff --git a/.github/workflows/go-fuzz.yml b/.github/workflows/go-fuzz.yml new file mode 100644 index 00000000..42ba4b62 --- /dev/null +++ b/.github/workflows/go-fuzz.yml @@ -0,0 +1,49 @@ +name: Go Fuzz + +on: + push: + branches: + - main + pull_request: + merge_group: + types: + - checks_requested + +jobs: + fuzz: + name: go-fuzz + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: '1.21' + - name: Fuzz + env: + FUZZTIME: 30s + run: make fuzz + - name: Upload fuzz failure seed corpus as run artifact + if: failure() + uses: actions/upload-artifact@v4 + id: testdata-upload + with: + name: testdata + path: '**/testdata/fuzz' + - name: Output message + if: failure() + shell: bash + run: | + echo -e 'Fuzz test failed on commit https://github.com/${{ github.repository }}/commit/${{ github.event.pull_request.head.sha }}. To troubleshoot locally, use the GitHub CLI to download the seed corpus by running:\n $ gh run download ${ github.run_id } -n testdata\nAlternatively, download from:\n ${{ steps.testdata-upload.outputs.artifact-url }}' + - name: Post PR comment + uses: actions/github-script@v7 + if: failure() && github.event_name == 'pull_request' + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'Fuzz test failed on commit ${{ github.event.pull_request.head.sha }}. To troubleshoot locally, download the seed corpus using [GitHub CLI](https://cli.github.com) by running:\n```shell\ngh run download ${{ github.run_id }} -n testdata\n```\nAlternatively, download directly from [here](${{ steps.testdata-upload.outputs.artifact-url }}).' + }) + \ No newline at end of file diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml index 3857a2a7..8fb1c7f4 100644 --- a/.github/workflows/go-test.yml +++ b/.github/workflows/go-test.yml @@ -5,6 +5,7 @@ on: push: branches: ["main"] workflow_dispatch: + merge_group: permissions: contents: read diff --git a/.github/workflows/publish-ghcr.yml b/.github/workflows/publish-ghcr.yml index e1899999..b4745fa8 100644 --- a/.github/workflows/publish-ghcr.yml +++ b/.github/workflows/publish-ghcr.yml @@ -1,4 +1,4 @@ -name: Continuous Integration +name: Container on: push: @@ -10,7 +10,7 @@ on: jobs: publish: - name: Publish Container + name: publish runs-on: ubuntu-latest permissions: contents: read