refactor!: rename "main module" to "passthrough" #819
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This workflow builds and tests a golang project for every commit in a PR | |
| # | |
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | |
| name: Go | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| permissions: | |
| contents: read | |
| # Optional: allow read access to pull request. Use with `only-new-issues` option. | |
| # pull-requests: read | |
| jobs: | |
| # This job identifies all commits that need to be tested | |
| # For push events: only tests the latest commit | |
| # For PR events: tests every commit in the PR | |
| commit_list: | |
| name: Get Commits to Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Checkout with full history to enable commit listing | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| # For push events: only test the latest commit (GITHUB_SHA) | |
| - name: Get commit list (push) | |
| id: get_commit_list_push | |
| if: ${{ github.event_name == 'push' }} | |
| run: | | |
| # Create a single output variable with the latest commit | |
| echo "id0=$GITHUB_SHA" > $GITHUB_OUTPUT | |
| # Add commit URL to the workflow summary for visibility | |
| echo "List of tested commits:" > $GITHUB_STEP_SUMMARY | |
| echo "- https://github.com/${{ github.repository }}/commit/$GITHUB_SHA" >> $GITHUB_STEP_SUMMARY | |
| # For PR events: get all commits in the PR | |
| - name: Get commit list (PR) | |
| id: get_commit_list_pr | |
| if: ${{ github.event_name == 'pull_request' }} | |
| run: | | |
| # Get all commits between base branch and PR head, in oldest to newest order | |
| git rev-list --reverse refs/remotes/origin/${{ github.base_ref }}..${{ github.event.pull_request.head.sha }} | | |
| awk '{ print "id" NR "=" $1 }' > $GITHUB_OUTPUT | |
| # If the merge commit differs from the PR head, also test the merge commit | |
| git diff --quiet ${{ github.event.pull_request.head.sha }} ${{ github.sha }} || | |
| echo "id0=$GITHUB_SHA" >> $GITHUB_OUTPUT | |
| # Create a summary with links to all commits | |
| echo "List of tested commits:" > $GITHUB_STEP_SUMMARY | |
| sed -n 's,^id[0-9]\+=\(.*\),- https://github.com/${{ github.repository }}/commit/\1,p' -- $GITHUB_OUTPUT >> $GITHUB_STEP_SUMMARY | |
| # Make the list of commits available to downstream jobs | |
| outputs: | |
| commits: ${{ toJSON(steps.*.outputs.*) }} | |
| # Lint job - runs once per workflow execution, not per commit | |
| golangci-lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: 'go.mod' | |
| - run: go version | |
| - name: golangci-lint | |
| uses: golangci/golangci-lint-action@v9 | |
| with: | |
| version: v2.6.1 | |
| # Build and test each commit for both architectures | |
| # Uses a matrix strategy to create separate job runs for each combination of commit and architecture | |
| per_commit_build_test: | |
| name: Build & Test ${{ matrix.arch }} | |
| runs-on: ubuntu-latest | |
| needs: commit_list | |
| strategy: | |
| # Don't stop all tests if one commit/arch fails | |
| fail-fast: false | |
| matrix: | |
| # Create matrix entries for each combination of commit and architecture | |
| commit: ${{ fromJSON(needs.commit_list.outputs.commits) }} | |
| arch: [amd64, arm64] | |
| steps: | |
| # Checkout the specific commit to test | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ matrix.commit }} | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: 'go.mod' | |
| - run: go version | |
| - name: Build ${{ matrix.commit }} for ${{ matrix.arch }} | |
| run: GOARCH=${{ matrix.arch }} go build -v ./... | |
| - name: Unit test ${{ matrix.commit }} for ${{ matrix.arch }} | |
| run: go test -v ./... | |
| # License check runs once per workflow execution | |
| check-license-lines: | |
| name: Check License Lines | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: kt3k/license_checker@v1.0.6 |