diff --git a/.github/workflows/_build-and-test-locally.yml b/.github/workflows/_build-and-test-locally.yml index e31d3dec5b..4f7d6026f2 100644 --- a/.github/workflows/_build-and-test-locally.yml +++ b/.github/workflows/_build-and-test-locally.yml @@ -28,6 +28,16 @@ on: required: false default: 'disabled' type: string + test-selection: + description: 'specification of selected test(s) to run' + required: false + default: '' + type: string + test-run-count: + description: 'number of runs to perform for selected tests' + required: false + default: 1 + type: number defaults: run: @@ -381,14 +391,15 @@ jobs: run_with_real_s3: true real_s3_bucket: neon-github-ci-tests real_s3_region: eu-central-1 - rerun_failed: true + rerun_failed: ${{ inputs.test-run-count == 1 }} pg_version: ${{ matrix.pg_version }} sanitizers: ${{ inputs.sanitizers }} aws-oicd-role-arn: ${{ vars.DEV_AWS_OIDC_ROLE_ARN }} # `--session-timeout` is equal to (timeout-minutes - 10 minutes) * 60 seconds. # Attempt to stop tests gracefully to generate test reports # until they are forcibly stopped by the stricter `timeout-minutes` limit. - extra_params: --session-timeout=${{ inputs.sanitizers != 'enabled' && 3000 || 10200 }} + extra_params: --session-timeout=${{ inputs.sanitizers != 'enabled' && 3000 || 10200 }} --count=${{ inputs.test-run-count }} + ${{ inputs.test-selection != '' && format('-k "{0}"', inputs.test-selection) || '' }} env: TEST_RESULT_CONNSTR: ${{ secrets.REGRESS_TEST_RESULT_CONNSTR_NEW }} CHECK_ONDISK_DATA_COMPATIBILITY: nonempty diff --git a/.github/workflows/build_and_run_selected_test.yml b/.github/workflows/build_and_run_selected_test.yml new file mode 100644 index 0000000000..f22fe310ab --- /dev/null +++ b/.github/workflows/build_and_run_selected_test.yml @@ -0,0 +1,120 @@ +name: Build and Run Selected Test + +on: + workflow_dispatch: + inputs: + test-selection: + description: 'Specification of selected test(s), as accepted by pytest -k' + required: true + type: string + run-count: + description: 'Number of test runs to perform' + required: true + type: number + archs: + description: 'Archs to run tests on, e. g.: ["x64", "arm64"]' + default: '["x64"]' + required: true + type: string + build-types: + description: 'Build types to run tests on, e. g.: ["debug", "release"]' + default: '["release"]' + required: true + type: string + pg-versions: + description: 'Postgres versions to use for testing, e.g,: [{"pg_version":"v16"}, {"pg_version":"v17"}])' + default: '[{"pg_version":"v17"}]' + required: true + type: string + +defaults: + run: + shell: bash -euxo pipefail {0} + +env: + RUST_BACKTRACE: 1 + COPT: '-Werror' + +jobs: + meta: + uses: ./.github/workflows/_meta.yml + with: + github-event-name: ${{ github.event_name }} + github-event-json: ${{ toJSON(github.event) }} + + build-and-test-locally: + needs: [ meta ] + strategy: + fail-fast: false + matrix: + arch: ${{ fromJson(inputs.archs) }} + build-type: ${{ fromJson(inputs.build-types) }} + uses: ./.github/workflows/_build-and-test-locally.yml + with: + arch: ${{ matrix.arch }} + build-tools-image: ghcr.io/neondatabase/build-tools:pinned-bookworm + build-tag: ${{ needs.meta.outputs.build-tag }} + build-type: ${{ matrix.build-type }} + test-cfg: ${{ inputs.pg-versions }} + test-selection: ${{ inputs.test-selection }} + test-run-count: ${{ fromJson(inputs.run-count) }} + secrets: inherit + + create-test-report: + needs: [ build-and-test-locally ] + if: ${{ !cancelled() }} + permissions: + id-token: write # aws-actions/configure-aws-credentials + statuses: write + contents: write + pull-requests: write + outputs: + report-url: ${{ steps.create-allure-report.outputs.report-url }} + + runs-on: [ self-hosted, small ] + container: + image: ghcr.io/neondatabase/build-tools:pinned-bookworm + credentials: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + options: --init + + steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0 + with: + egress-policy: audit + + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Create Allure report + if: ${{ !cancelled() }} + id: create-allure-report + uses: ./.github/actions/allure-report-generate + with: + store-test-results-into-db: true + aws-oicd-role-arn: ${{ vars.DEV_AWS_OIDC_ROLE_ARN }} + env: + REGRESS_TEST_RESULT_CONNSTR_NEW: ${{ secrets.REGRESS_TEST_RESULT_CONNSTR_DEV }} + + - uses: actions/github-script@v7 + if: ${{ !cancelled() }} + with: + # Retry script for 5XX server errors: https://github.com/actions/github-script#retries + retries: 5 + script: | + const report = { + reportUrl: "${{ steps.create-allure-report.outputs.report-url }}", + reportJsonUrl: "${{ steps.create-allure-report.outputs.report-json-url }}", + } + + const coverage = {} + + const script = require("./scripts/comment-test-report.js") + await script({ + github, + context, + fetch, + report, + coverage, + })