|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + pbm_branch: |
| 7 | + description: "PBM branch" |
| 8 | + required: false |
| 9 | + tests_ver: |
| 10 | + description: "Tests version" |
| 11 | + required: false |
| 12 | + go_ver: |
| 13 | + description: "Golang version" |
| 14 | + required: false |
| 15 | + pr_ver: |
| 16 | + description: "PR version" |
| 17 | + required: false |
| 18 | + |
| 19 | + pull_request: |
| 20 | + branches: |
| 21 | + - main |
| 22 | + - dev |
| 23 | + paths-ignore: |
| 24 | + - "e2e-tests/**" |
| 25 | + - "packaging/**" |
| 26 | + - "version/**" |
| 27 | + |
| 28 | + push: |
| 29 | + branches: |
| 30 | + - main |
| 31 | + - dev |
| 32 | + paths-ignore: |
| 33 | + - "e2e-tests/**" |
| 34 | + - "packaging/**" |
| 35 | + - "version/**" |
| 36 | + |
| 37 | +jobs: |
| 38 | + test: |
| 39 | + runs-on: ubuntu-latest |
| 40 | + timeout-minutes: 180 |
| 41 | + strategy: |
| 42 | + fail-fast: false |
| 43 | + matrix: |
| 44 | + psmdb: ["7.0", "8.0"] |
| 45 | + shard: [0, 1, 2, 3, 4, 5, 6] |
| 46 | + env: |
| 47 | + PBM_BRANCH: ${{ github.event.inputs.pbm_branch || github.ref_name }} |
| 48 | + GO_VER: ${{ github.event.inputs.go_ver || '1.25-bookworm' }} |
| 49 | + PR_NUMBER: ${{ github.event.number|| github.event.inputs.pr_ver }} |
| 50 | + MAKE_TARGET: 'build-cover' |
| 51 | + steps: |
| 52 | + - name: Checkout testing repo |
| 53 | + uses: actions/checkout@v4 |
| 54 | + with: |
| 55 | + repository: Percona-QA/psmdb-testing |
| 56 | + ref: ${{ github.event.inputs.tests_ver || 'main'}} |
| 57 | + path: psmdb-testing |
| 58 | + |
| 59 | + - name: Setup environment with PSMDB ${{ matrix.psmdb }} for PBM PR/branch ${{ github.event.pull_request.title || env.PR_NUMBER || env.PBM_BRANCH }} |
| 60 | + run: | |
| 61 | + PSMDB=perconalab/percona-server-mongodb:${{ matrix.psmdb }} docker compose build easyrsa |
| 62 | + PSMDB=perconalab/percona-server-mongodb:${{ matrix.psmdb }} docker compose build |
| 63 | + docker compose up -d |
| 64 | + working-directory: psmdb-testing/pbm-functional/pytest |
| 65 | + |
| 66 | + - name: Run pytest shard number ${{ matrix.shard }} on PSMDB ${{ matrix.psmdb }} for PBM PR/branch ${{ github.event.pull_request.title || env.PR_NUMBER || env.PBM_BRANCH }} |
| 67 | + run: | |
| 68 | + docker compose run test pytest -s --junitxml=junit.xml --shard-id=${{ matrix.shard }} --num-shards=7 -m 'not jenkins and not skip' |
| 69 | + working-directory: psmdb-testing/pbm-functional/pytest |
| 70 | + |
| 71 | + - name: Fetch coverage files |
| 72 | + run: | |
| 73 | + docker compose run --rm golang_reports cp -r /gocoverdir/reports /test |
| 74 | + sudo chmod -R 777 reports |
| 75 | + working-directory: psmdb-testing/pbm-functional/pytest |
| 76 | + if: success() || failure() |
| 77 | + |
| 78 | + - name: Upload coverage reports |
| 79 | + uses: actions/upload-artifact@v4 |
| 80 | + with: |
| 81 | + name: reports-${{ matrix.shard }}-${{ matrix.psmdb }} |
| 82 | + path: psmdb-testing/pbm-functional/pytest/reports/ |
| 83 | + if: success() || failure() |
| 84 | + |
| 85 | + - name: Publish Test Report |
| 86 | + uses: mikepenz/action-junit-report@v4 |
| 87 | + if: success() || failure() |
| 88 | + with: |
| 89 | + report_paths: "**/junit.xml" |
| 90 | + |
| 91 | + coverage: |
| 92 | + if: ${{ always() }} |
| 93 | + needs: test |
| 94 | + runs-on: ubuntu-latest |
| 95 | + steps: |
| 96 | + - uses: actions/checkout@v4 |
| 97 | + - name: Set up Go |
| 98 | + uses: actions/setup-go@v5 |
| 99 | + with: |
| 100 | + go-version-file: 'go.mod' |
| 101 | + check-latest: true |
| 102 | + - name: Download all coverage reports |
| 103 | + uses: actions/download-artifact@v4 |
| 104 | + with: |
| 105 | + path: reports |
| 106 | + pattern: reports-* |
| 107 | + merge-multiple: true |
| 108 | + - name: Merge coverage reports |
| 109 | + run: | |
| 110 | + go tool covdata textfmt -i=./reports -o ./coverage.txt |
| 111 | + - name: Upload coverage to Codecov |
| 112 | + uses: codecov/codecov-action@v3 |
| 113 | + with: |
| 114 | + files: ./coverage.txt |
| 115 | + flags: integration |
| 116 | + fail_ci_if_error: false |
| 117 | + token: ${{ secrets.CODECOV_TOKEN }} |
0 commit comments