|
| 1 | +name: Go SDK CI |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + paths: |
| 5 | + - go/** |
| 6 | + |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + paths: |
| 11 | + - go/** |
| 12 | + |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +env: |
| 16 | + JUNIT_OUTPUT_DIR: results |
| 17 | + JUNIT_ARTIFACT_DIR: gosdk-test-results |
| 18 | + |
| 19 | +jobs: |
| 20 | + unit: |
| 21 | + name: Unit - ${{ matrix.os }} / Go ${{ matrix.go-version }} |
| 22 | + env: |
| 23 | + GO_JUNIT_OUTPUT_NAME: ${{ matrix.os }}.gosdkunitresult${{ matrix.go-version }}.xml |
| 24 | + runs-on: ${{ matrix.os }}-latest |
| 25 | + |
| 26 | + strategy: |
| 27 | + matrix: |
| 28 | + os: |
| 29 | + - ubuntu |
| 30 | + go-version: [1.17.6, 1.16.13] |
| 31 | + |
| 32 | + steps: |
| 33 | + - name: Cancel Previous Runs |
| 34 | + |
| 35 | + with: |
| 36 | + access_token: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + |
| 38 | + - name: Repo Checkout |
| 39 | + uses: actions/checkout@v2 |
| 40 | + |
| 41 | + - name: Install Go ${{ matrix.go-version }} |
| 42 | + uses: actions/setup-go@v2 |
| 43 | + with: |
| 44 | + go-version: ${{ matrix.go-version }} |
| 45 | + |
| 46 | + - name: Install dependencies |
| 47 | + run: go get -u github.com/jstemmer/go-junit-report |
| 48 | + |
| 49 | + - name: Run unit tests |
| 50 | + run: | |
| 51 | + mkdir ${{ env.JUNIT_OUTPUT_DIR }} |
| 52 | + cd go/rtl |
| 53 | + go test -v 2>&1 | go-junit-report > ../../${{ env.JUNIT_OUTPUT_DIR }}/${{ env.GO_JUNIT_OUTPUT_NAME }} |
| 54 | +
|
| 55 | + - name: Upload Go unit test results |
| 56 | + if: ${{ always() }} |
| 57 | + uses: actions/upload-artifact@v2 |
| 58 | + with: |
| 59 | + name: ${{ env.JUNIT_ARTIFACT_DIR }} |
| 60 | + path: ${{ env.JUNIT_OUTPUT_DIR }} |
| 61 | + |
| 62 | + publish-test-results: |
| 63 | + needs: unit |
| 64 | + if: success() || failure() |
| 65 | + runs-on: ubuntu-latest |
| 66 | + |
| 67 | + steps: |
| 68 | + - name: Download Artifacts |
| 69 | + uses: actions/download-artifact@v2 |
| 70 | + with: |
| 71 | + path: artifacts |
| 72 | + |
| 73 | + - name: Publish All Test Results |
| 74 | + |
| 75 | + with: |
| 76 | + # Cosmetic issue with `check_name` being associated to the wrong |
| 77 | + # workflow: https://github.com/EnricoMi/publish-unit-test-result-action/issues/12 |
| 78 | + check_name: Go Tests |
| 79 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 80 | + report_individual_runs: true |
| 81 | + hide_comments: orphaned commits |
| 82 | + check_run_annotations_branch: '*' |
| 83 | + files: 'artifacts/${{ env.JUNIT_ARTIFACT_DIR }}/*.xml' |
0 commit comments