|
| 1 | +name: Compliance Tests |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, synchronize, reopened, edited] |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +# Cancels in-progress workflows for a PR when updated |
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +# Please define `build.args.GEOS_TPL_TAG` in `.devcontainer/devcontainer.json` |
| 14 | + |
| 15 | +jobs: |
| 16 | + # Checks if PR title follows conventional semantics |
| 17 | + semantic_pull_request: |
| 18 | + permissions: |
| 19 | + pull-requests: write # for amannn/action-semantic-pull-request to analyze PRs and |
| 20 | + statuses: write # for amannn/action-semantic-pull-request to mark status of analyzed PR |
| 21 | + contents: read |
| 22 | + runs-on: ubuntu-latest |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Check if the PR name has conventional semantics |
| 26 | + if: github.event_name == 'pull_request' |
| 27 | + |
| 28 | + id: lint_pr_title |
| 29 | + env: |
| 30 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 31 | + with: |
| 32 | + wip: true |
| 33 | + # Configure that a scope doesn't need to be provided. |
| 34 | + requireScope: false |
| 35 | + |
| 36 | + # Jobs will be cancelled if PR is a draft. |
| 37 | + # PR status must be "Open" to run CI. |
| 38 | + is_not_draft_pull_request: |
| 39 | + needs: [semantic_pull_request] |
| 40 | + # Everywhere in this workflow, we use the most recent ubuntu distribution available in Github Actions |
| 41 | + # to ensure maximum support of google cloud's sdk. |
| 42 | + runs-on: ubuntu-22.04 |
| 43 | + outputs: |
| 44 | + DOCKER_IMAGE_TAG: ${{ steps.extract_docker_image_tag.outputs.DOCKER_IMAGE_TAG }} |
| 45 | + steps: |
| 46 | + - name: Check that the PR is not a draft (cancel rest of jobs otherwise) |
| 47 | + id: extract_pr_info |
| 48 | + run: | |
| 49 | + if [[ ${{github.event_name}} == 'pull_request' ]]; then |
| 50 | + # We do not rely on the `github.event.pull_request.labels` information since it's cached at the job. |
| 51 | + # Changing labels or assignee in the PR would not allow to simply re-run the job with a different outcome. |
| 52 | + pr_json=$(curl -H "Accept: application/vnd.github+json" https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.number }}) |
| 53 | + |
| 54 | + # We stop the workflow if the pr is draft |
| 55 | + draft_status=$(echo ${pr_json} | jq '.draft') |
| 56 | + echo "Draft status of PR is ${draft_status}." |
| 57 | + if [[ $draft_status == true ]]; then exit 1 ; fi |
| 58 | + fi |
| 59 | +
|
| 60 | + |
| 61 | + # The TPL tag is contained in the codespaces configuration to avoid duplications. |
| 62 | + - name: Checkout .devcontainer/devcontainer.json |
| 63 | + |
| 64 | + with: |
| 65 | + sparse-checkout: | |
| 66 | + .devcontainer/devcontainer.json |
| 67 | + sparse-checkout-cone-mode: false |
| 68 | + submodules: false |
| 69 | + lfs: false |
| 70 | + fetch-depth: 1 |
| 71 | + - name: Extract docker image tag |
| 72 | + id: extract_docker_image_tag |
| 73 | + run: | |
| 74 | + echo "DOCKER_IMAGE_TAG=$(jq '.build.args.GEOS_TPL_TAG' -r .devcontainer/devcontainer.json)" >> "$GITHUB_OUTPUT" |
| 75 | +
|
| 76 | + # PR must be assigned to be merged. |
| 77 | + # This job will fail if this is not the case. |
| 78 | + if_not_unassigned_pull_request: |
| 79 | + needs: [is_not_draft_pull_request] |
| 80 | + runs-on: ubuntu-22.04 |
| 81 | + steps: |
| 82 | + - name: If this is a PR, Check that it is assigned |
| 83 | + run: | |
| 84 | + if [[ ${{github.event_name}} != 'pull_request' ]]; then exit 0 ; fi |
| 85 | + pr_json=$(curl -H "Accept: application/vnd.github+json" https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.number }}) |
| 86 | + NUM_ASSIGNEES=$(echo ${pr_json} | jq '.assignees | length') |
| 87 | + echo "There are ${NUM_ASSIGNEES} assignees on this PR." |
| 88 | + if [[ $NUM_ASSIGNEES == 0 ]]; then exit 1 ; fi |
| 89 | +
|
| 90 | + # Validates that the PR is still pointing to the HEAD of the main branch of the submodules repositories. |
| 91 | + # (There are exceptions, read the script about those). |
| 92 | + are_submodules_in_sync: |
| 93 | + needs: [is_not_draft_pull_request] |
| 94 | + runs-on: ubuntu-22.04 |
| 95 | + steps: |
| 96 | + # The integrated test submodule repository contains large data (using git lfs). |
| 97 | + # To save time (and money) we do not let Github Actions automatically clone all our (lfs) subrepositories and do it by hand. |
| 98 | + - name: Checkout Repository |
| 99 | + |
| 100 | + with: |
| 101 | + # Let script update submodules; Github Actions submodule history causes error |
| 102 | + submodules: false |
| 103 | + lfs: false |
| 104 | + fetch-depth: 1 |
| 105 | + - name: Check that submodules are up to date |
| 106 | + run: "scripts/test_submodule_updated.sh" |
| 107 | + |
| 108 | + check_code_style_and_documentation: |
| 109 | + name: ${{ matrix.name }} |
| 110 | + needs: [is_not_draft_pull_request] |
| 111 | + strategy: |
| 112 | + fail-fast : false |
| 113 | + matrix: |
| 114 | + include: |
| 115 | + # Validates the code-style using uncrustify |
| 116 | + - name: Check code style |
| 117 | + BUILD_AND_TEST_ARGS: --test-code-style |
| 118 | + # Validates that the documentation generated using doxygen has no hole. |
| 119 | + - name: Check documentation |
| 120 | + BUILD_AND_TEST_ARGS: --test-documentation |
| 121 | + uses: ./.github/workflows/build_and_test.yml |
| 122 | + with: |
| 123 | + BUILD_AND_TEST_CLI_ARGS: ${{ matrix.BUILD_AND_TEST_ARGS }} |
| 124 | + CMAKE_BUILD_TYPE: Release |
| 125 | + DOCKER_IMAGE_TAG: ${{ needs.is_not_draft_pull_request.outputs.DOCKER_IMAGE_TAG }} |
| 126 | + DOCKER_REPOSITORY: geosx/ubuntu20.04-gcc9 |
| 127 | + RUNS_ON: ubuntu-22.04 |
| 128 | + USE_SCCACHE: false |
| 129 | + |
| 130 | + baseline_log: |
| 131 | + needs: [is_not_draft_pull_request] |
| 132 | + runs-on: ubuntu-22.04 |
| 133 | + steps: |
| 134 | + - name: Checkout Repository |
| 135 | + |
| 136 | + with: |
| 137 | + submodules: false |
| 138 | + lfs: false |
| 139 | + fetch-depth: 0 |
| 140 | + sparse-checkout: | |
| 141 | + scripts |
| 142 | + - name: Check that the baseline logs are modified if rebaselines are detected |
| 143 | + run: "scripts/check_baseline_log.sh" |
| 144 | + |
| 145 | + code_coverage: |
| 146 | + needs: |
| 147 | + - is_not_draft_pull_request |
| 148 | + uses: ./.github/workflows/build_and_test.yml |
| 149 | + secrets: inherit |
| 150 | + with: |
| 151 | + BUILD_AND_TEST_CLI_ARGS: "--no-run-unit-tests" |
| 152 | + CMAKE_BUILD_TYPE: Debug |
| 153 | + CODE_COVERAGE: true |
| 154 | + DOCKER_IMAGE_TAG: ${{ needs.is_not_draft_pull_request.outputs.DOCKER_IMAGE_TAG }} |
| 155 | + DOCKER_REPOSITORY: geosx/ubuntu22.04-gcc11 |
| 156 | + ENABLE_HYPRE: ON |
| 157 | + ENABLE_TRILINOS: OFF |
| 158 | + GCP_BUCKET: geosx/ubuntu22.04-gcc11 |
| 159 | + RUNS_ON: Runner_4core_16GB |
| 160 | + |
| 161 | + |
| 162 | + |
| 163 | + # Convenience job - passes when all other jobs have passed (must pass the CUDA jobs). |
| 164 | + # check_that_all_jobs_succeeded: |
| 165 | + # runs-on: ubuntu-22.04 |
| 166 | + # needs: |
| 167 | + # - if_not_unassigned_pull_request |
| 168 | + # - are_submodules_in_sync |
| 169 | + # - check_code_style_and_documentation |
| 170 | + # - cpu_builds |
| 171 | + # - cuda_builds |
| 172 | + # - run_integrated_tests |
| 173 | + # if: ${{ always() }} |
| 174 | + # steps: |
| 175 | + # - run: | |
| 176 | + # echo "if_not_unassigned_pull_request: ${{needs.if_not_unassigned_pull_request.result}}" |
| 177 | + # echo "are_submodules_in_sync: ${{needs.are_submodules_in_sync.result}}" |
| 178 | + # echo "check_code_style_and_documentation: ${{needs.check_code_style_and_documentation.result}}" |
| 179 | + # echo "cpu_builds: ${{needs.cpu_builds.result}}" |
| 180 | + # echo "cuda_builds: ${{needs.cuda_builds.result}}" |
| 181 | + # echo "run_integrated_tests: ${{needs.run_integrated_tests.result}} " |
| 182 | + # ${{ |
| 183 | + # needs.if_not_unassigned_pull_request.result == 'success' && |
| 184 | + # needs.are_submodules_in_sync.result == 'success' && |
| 185 | + # needs.check_code_style_and_documentation.result == 'success' && |
| 186 | + # needs.cpu_builds.result == 'success' && |
| 187 | + # needs.cuda_builds.result == 'success' && |
| 188 | + # needs.run_integrated_tests.result == 'success' |
| 189 | + # }} |
0 commit comments