Dummy change #279
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
| # Copyright 2021 Google LLC | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| name: Checks | |
| on: | |
| push: | |
| branches: | |
| - "main" | |
| pull_request: | |
| concurrency: | |
| # Pushing new changes to a branch will cancel any in-progress CI runs | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| # Restrict jobs in this workflow to have no permissions by default; permissions | |
| # should be granted per job as needed using a dedicated `permissions` block | |
| permissions: {} | |
| jobs: | |
| ensure_snapshots_are_being_cleaned: | |
| permissions: | |
| contents: read # to fetch code (actions/checkout) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
| with: | |
| persist-credentials: false | |
| - run: scripts/report_uncleaned_snapshots.py | |
| format: | |
| permissions: | |
| contents: read # to fetch code (actions/checkout) | |
| name: prettier | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
| with: | |
| persist-credentials: false | |
| - name: Run lint action | |
| uses: ./.github/workflows/format-action | |
| lint: | |
| permissions: | |
| contents: read # to fetch code (actions/checkout) | |
| name: golangci-lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
| with: | |
| persist-credentials: false | |
| - name: Set up Go | |
| uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 | |
| with: | |
| go-version-file: .go-version | |
| check-latest: true | |
| - name: Run lint action | |
| uses: ./.github/workflows/lint-action | |
| tests: | |
| permissions: | |
| contents: read # to fetch code (actions/checkout) | |
| name: Run unit tests | |
| outputs: | |
| coverage_ubuntu-latest: ${{steps.test.outputs.coverage_ubuntu-latest}} | |
| coverage_macos-latest: ${{steps.test.outputs.coverage_macos-latest}} | |
| coverage_windows-latest: ${{steps.test.outputs.coverage_windows-latest}} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
| with: | |
| persist-credentials: false | |
| - name: Set up Go | |
| uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 | |
| with: | |
| go-version-file: .go-version | |
| check-latest: true | |
| - name: Run test action | |
| id: test | |
| uses: ./.github/workflows/test-action | |
| with: | |
| upload_coverage: "true" | |
| coverage: | |
| permissions: | |
| contents: read # to fetch code (actions/checkout) | |
| pull-requests: write | |
| needs: [tests] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
| with: | |
| persist-credentials: false | |
| - name: download coverages | |
| uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # 4.2.1 | |
| with: | |
| merge-multiple: "true" | |
| - name: download artifact (main.breakdown) | |
| id: download-main-breakdown | |
| uses: dawidd6/action-download-artifact@07ab29fd4a977ae4d2b275087cf67563dfdf0295 # v9 | |
| # TODO : Remove this once the repository is public as it should be able to access the artifact | |
| continue-on-error: true | |
| with: | |
| branch: main | |
| workflow_conclusion: success | |
| name: main.breakdown | |
| if_no_artifact_found: warn | |
| - name: check test coverage | |
| uses: vladopajic/go-test-coverage@e44e229d0edbb82c8b9d217f83ce14a878f95117 # 2.13.2 | |
| id: go-test-coverage | |
| with: | |
| profile: ubuntu-latest.cov,macos-latest.cov,windows-latest.cov | |
| # Save current coverage breakdown if current branch is main. It will be | |
| # uploaded as artifact in step below. | |
| breakdown-file-name: ${{ github.ref_name == 'main' && 'main.breakdown' || '' }} | |
| # If this is not main branch we want to show report including | |
| # file coverage difference from main branch. | |
| diff-base-breakdown-file-name: ${{ steps.download-main-breakdown.outputs.found_artifact == 'true' && 'main.breakdown' || '' }} | |
| - name: upload artifact (main.breakdown) | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # 4.6.2 | |
| if: github.ref_name == 'main' | |
| with: | |
| name: main.breakdown | |
| path: main.breakdown # as specified via `breakdown-file-name` | |
| if-no-files-found: error | |
| # Post coverage report as comment (update existing or create new) | |
| - name: post coverage report | |
| if: ${{github.event_name == 'pull_request'}} | |
| uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # 7.0.1 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const botCommentIdentifier = "## Go test coverage report"; | |
| const coverageReport = `${botCommentIdentifier}\n\n${{fromJSON(steps.go-test-coverage.outputs.report)}}`; | |
| // Try to find an existing comment from the bot | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo | |
| }); | |
| const botComment = comments.find(comment => comment.body.includes(botCommentIdentifier)); | |
| // Update existing comment or create a new one | |
| if (botComment) { | |
| await github.rest.issues.updateComment({ | |
| comment_id: botComment.id, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: coverageReport | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: coverageReport | |
| }); | |
| } |