ci: added sample packages to exercice CI pipelines #3
Workflow file for this run
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
| name: go test | ||
| on: | ||
| workflow_call: | ||
| jobs: | ||
| lint: | ||
| name: Lint | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| - uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: stable | ||
| check-latest: true | ||
| cache: true | ||
| - name: golangci-lint | ||
| uses: golangci/golangci-lint-action@v8 | ||
| with: | ||
| version: latest | ||
| only-new-issues: true | ||
| skip-cache: true | ||
| - name: Linting complete | ||
| run: | | ||
| echo "### Your changes to the go code look good. 👍" >> $GITHUB_STEP_SUMMARY | ||
| unit_tests: | ||
| name: Unit tests | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| os: [ ubuntu-latest, macos-latest, windows-latest ] | ||
| go_version: ['oldstable', 'stable' ] | ||
| steps: | ||
| - uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '${{ matrix.go_version }}' | ||
| check-latest: true | ||
| cache: true | ||
| - uses: actions/checkout@v5 | ||
| - name: Run unit tests | ||
| id: gotest | ||
| shell: bash | ||
| run: | | ||
| go test -v \ | ||
| -race \ | ||
| -coverprofile="coverage-${{ matrix.os }}.${{ matrix.go_version }}.out" \ | ||
| -covermode=atomic -coverpkg=$(go list)/... \ | ||
| ./... | ||
| - name: Report failed test | ||
| if: failure() | ||
| shell: bash | ||
| run: | | ||
| echo "test_result=\"| ${{ matrix.go_version }} | ${{ matrix.os }} | 🚫 ${{ steps.gotest.outcome }} | ${{ steps.gotest.outputs.duration }} |\"" >> $GITHUB_ENV | ||
| - name: Report successful test | ||
| shell: bash | ||
| run: | | ||
| echo "test_result=\"| ${{ matrix.go_version }} | ${{ matrix.os }} | ✅ ${{ steps.gotest.outcome }} | ${{ steps.gotest.outputs.duration }} |\"" >> $GITHUB_ENV | ||
| - name: Upload coverage to codecov | ||
| uses: codecov/codecov-action@v5 | ||
| with: | ||
| files: './coverage-${{ matrix.os }}.${{ matrix.go_version }}.out' | ||
| flags: '${{ matrix.go_version }}-${{ matrix.os }}' | ||
| fail_ci_if_error: false | ||
| verbose: true | ||
| all_tests: | ||
| needs: [ unit_tests ] # requires all unit_tests jobs to be successful. | ||
| name: All tests | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Tests complete | ||
| run: | | ||
| echo "All tests completed. 👍" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "| go version | OS | Result | Duration |" >> $GITHUB_STEP_SUMMARY | ||
| echo "|------------|----|--------|----------|" >> $GITHUB_STEP_SUMMARY | ||
| echo "${{ env.test_result }}" >> $GITHUB_STEP_SUMMARY | ||
| some_failed_tests: | ||
| if: ${{ job.status == 'failure' }} | ||
| needs: [ unit_tests ] # requires all unit_tests jobs to be completed, but not necessarily successfully. | ||
| name: Some tests have failed | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Tests complete | ||
| run: | | ||
| echo "Some tests have failed. 🚫" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "| go version | OS | Result | Duration |" >> $GITHUB_STEP_SUMMARY | ||
| echo "|------------|----|--------|----------|" >> $GITHUB_STEP_SUMMARY | ||
| echo "${{ env.test_result }}" >> $GITHUB_STEP_SUMMARY | ||