From bc885f0588c04c22c165ca21f5bb4133b3cd2e98 Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Mon, 7 Aug 2023 14:17:58 -0600 Subject: [PATCH 01/28] Create probited-strings.yml --- .github/workflows/probited-strings.yml | 47 ++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/probited-strings.yml diff --git a/.github/workflows/probited-strings.yml b/.github/workflows/probited-strings.yml new file mode 100644 index 000000000000..4cc393c7d449 --- /dev/null +++ b/.github/workflows/probited-strings.yml @@ -0,0 +1,47 @@ +# This defines the name of the workflow as it will appear in the "Actions" tab of the GitHub repository. +name: 'Prohibited Strings' + +# The `on` key lets you define the events that trigger when the workflow is run. You can define multiple events here. For more information, see "[AUTOTITLE](/actions/using-workflows/triggering-a-workflow#using-events-to-trigger-workflows)." +on: +# Add the `workflow_dispatch` event if you want to be able to manually run this workflow from the UI. For more information, see [`workflow_dispatch`](/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch). + workflow_dispatch: + # Add the `push` event, so that the workflow runs automatically every time a commit is pushed to a branch called `main`. For more information, see [`push`](/actions/using-workflows/events-that-trigger-workflows#push). + # Add the `pull_request` event, so that the workflow runs automatically every time a pull request is created or updated. For more information, see [`pull_request`](/actions/using-workflows/events-that-trigger-workflows#pull_request). + pull_request: + branches: + - 'develop' + +# The `jobs` key groups together all the jobs that run in the workflow file. +jobs: + # This line defines a job with the ID `check-links` that is stored within the `jobs` key. + mpi_comm_world: + # The `runs-on` key in this example configures the job to run on a GitHub-hosted runner or a self-hosted runner, depending on the repository running the workflow. + # + # In this example, the job will run on a self-hosted runner if the repository is named `docs-internal` and is within the `github` organization. If the repository doesn't match this path, then it will run on an `ubuntu-latest` runner hosted by GitHub. For more information on these options, see "[AUTOTITLE](/actions/using-jobs/choosing-the-runner-for-a-job)." + runs-on: ubuntu-latest + # The `steps` key groups together all the steps that will run as part of the `check-links` job. Each job in a workflow has its own `steps` section. + steps: + # The `uses` key tells the job to retrieve the action named `actions/checkout`. This is an action that checks out your repository and downloads it to the runner, allowing you to run actions against your code (such as testing tools). You must use the checkout action any time your workflow will use the repository's code or you are using an action defined in the repository. + - name: Checkout + uses: actions/checkout@v3 + + # The `run` key tells the job to execute a command on the runner. In this example, `npm ci` is used to install the npm software packages for the project. + - name: Deps + run: yum install -y grep git + + # This step uses the `trilom/file-changes-action` action to gather all the changed files. This example is pinned to a specific version of the action, using the `a6ca26c14274c33b15e6499323aac178af06ad4b` SHA. + # + # In this example, this step creates the file "${{ env.HOME }}/files.json", among others. + - id: file_changes + uses: trilom/file-changes-action@a6ca26c14274c33b15e6499323aac178af06ad4b + with: + fileOutput: 'json' + + # To help with verification, this step lists the contents of `files.json`. This will be visible in the workflow run's log, and can be useful for debugging. + - name: Show files changed + run: echo '${{ steps.file_changes.outputs.files}}' + + # This step uses the `run` command to execute a script that is stored in the repository at `script/rendered-content-link-checker.mjs` and passes all the parameters it needs to run. + - name: Find illegal MPI_COMM_WORLD strings + run: | + grep MPI_COMM_WORLD '${{ steps.file_changes.outputs.files}}' From b81053763e8f940f76d6c968d8d94414f5ce56ef Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Mon, 7 Aug 2023 14:18:50 -0600 Subject: [PATCH 02/28] Update probited-strings.yml --- .github/workflows/probited-strings.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/probited-strings.yml b/.github/workflows/probited-strings.yml index 4cc393c7d449..85ab4a811895 100644 --- a/.github/workflows/probited-strings.yml +++ b/.github/workflows/probited-strings.yml @@ -10,6 +10,7 @@ on: pull_request: branches: - 'develop' + - 'master' # The `jobs` key groups together all the jobs that run in the workflow file. jobs: From 469fa755a3b00081571ebf72ea2f506a9e167649 Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Mon, 7 Aug 2023 14:20:21 -0600 Subject: [PATCH 03/28] Update probited-strings.yml --- .github/workflows/probited-strings.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/probited-strings.yml b/.github/workflows/probited-strings.yml index 85ab4a811895..e67048e89ccf 100644 --- a/.github/workflows/probited-strings.yml +++ b/.github/workflows/probited-strings.yml @@ -26,10 +26,6 @@ jobs: - name: Checkout uses: actions/checkout@v3 - # The `run` key tells the job to execute a command on the runner. In this example, `npm ci` is used to install the npm software packages for the project. - - name: Deps - run: yum install -y grep git - # This step uses the `trilom/file-changes-action` action to gather all the changed files. This example is pinned to a specific version of the action, using the `a6ca26c14274c33b15e6499323aac178af06ad4b` SHA. # # In this example, this step creates the file "${{ env.HOME }}/files.json", among others. From 0654fe43918174005afb678bb2c55438328c045c Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Mon, 7 Aug 2023 14:23:10 -0600 Subject: [PATCH 04/28] Update probited-strings.yml --- .github/workflows/probited-strings.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/probited-strings.yml b/.github/workflows/probited-strings.yml index e67048e89ccf..339f3fa10fee 100644 --- a/.github/workflows/probited-strings.yml +++ b/.github/workflows/probited-strings.yml @@ -32,7 +32,8 @@ jobs: - id: file_changes uses: trilom/file-changes-action@a6ca26c14274c33b15e6499323aac178af06ad4b with: - fileOutput: 'json' + output: ' ' + fileOutput: ' ' # To help with verification, this step lists the contents of `files.json`. This will be visible in the workflow run's log, and can be useful for debugging. - name: Show files changed From e1170b95ccb304834b930aed93775ae0cfe4e90d Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Mon, 7 Aug 2023 14:25:56 -0600 Subject: [PATCH 05/28] Add a file that should fail the new check --- mybadfile | 1 + 1 file changed, 1 insertion(+) create mode 100644 mybadfile diff --git a/mybadfile b/mybadfile new file mode 100644 index 000000000000..849bfda8ac96 --- /dev/null +++ b/mybadfile @@ -0,0 +1 @@ +MPI_COMM_WORLD() From bfd725761d1a0cfdd7a51969495fa912b2ec256c Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Mon, 7 Aug 2023 14:31:55 -0600 Subject: [PATCH 06/28] Update probited-strings.yml --- .github/workflows/probited-strings.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/probited-strings.yml b/.github/workflows/probited-strings.yml index 339f3fa10fee..7b5b001e9556 100644 --- a/.github/workflows/probited-strings.yml +++ b/.github/workflows/probited-strings.yml @@ -42,4 +42,9 @@ jobs: # This step uses the `run` command to execute a script that is stored in the repository at `script/rendered-content-link-checker.mjs` and passes all the parameters it needs to run. - name: Find illegal MPI_COMM_WORLD strings run: | - grep MPI_COMM_WORLD '${{ steps.file_changes.outputs.files}}' + if ! grep MPI_COMM_WORLD ${{steps.file_changes.outputs.files}}; + then + echo "The following changed files contain MPI_COMM_WORLD, which is not allowed: + grep MPI_COMM_WORLD ${{steps.file_changes.outputs.files}} + exit 1 + fi From 53c0ad0f1a624b2cc3bb548078fb3f5b985b2f84 Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Mon, 7 Aug 2023 14:33:35 -0600 Subject: [PATCH 07/28] Update probited-strings.yml --- .github/workflows/probited-strings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/probited-strings.yml b/.github/workflows/probited-strings.yml index 7b5b001e9556..817908c10ac4 100644 --- a/.github/workflows/probited-strings.yml +++ b/.github/workflows/probited-strings.yml @@ -44,7 +44,7 @@ jobs: run: | if ! grep MPI_COMM_WORLD ${{steps.file_changes.outputs.files}}; then - echo "The following changed files contain MPI_COMM_WORLD, which is not allowed: + echo "The following changed files contain MPI_COMM_WORLD, which is not allowed:" grep MPI_COMM_WORLD ${{steps.file_changes.outputs.files}} exit 1 fi From be4bc85000b1f79871f665e2d48b7051b3595cd2 Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Mon, 7 Aug 2023 14:37:17 -0600 Subject: [PATCH 08/28] Update probited-strings.yml --- .github/workflows/probited-strings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/probited-strings.yml b/.github/workflows/probited-strings.yml index 817908c10ac4..67cdecab1616 100644 --- a/.github/workflows/probited-strings.yml +++ b/.github/workflows/probited-strings.yml @@ -45,6 +45,6 @@ jobs: if ! grep MPI_COMM_WORLD ${{steps.file_changes.outputs.files}}; then echo "The following changed files contain MPI_COMM_WORLD, which is not allowed:" - grep MPI_COMM_WORLD ${{steps.file_changes.outputs.files}} + grep MPI_COMM_WORLD ${{steps.file_changes.outputs.files}} || true exit 1 fi From 252713f45689aaa389d81f956acaff2505ce9ee9 Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Mon, 7 Aug 2023 14:38:45 -0600 Subject: [PATCH 09/28] Update probited-strings.yml --- .github/workflows/probited-strings.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/probited-strings.yml b/.github/workflows/probited-strings.yml index 67cdecab1616..8869a6673d3f 100644 --- a/.github/workflows/probited-strings.yml +++ b/.github/workflows/probited-strings.yml @@ -42,9 +42,11 @@ jobs: # This step uses the `run` command to execute a script that is stored in the repository at `script/rendered-content-link-checker.mjs` and passes all the parameters it needs to run. - name: Find illegal MPI_COMM_WORLD strings run: | - if ! grep MPI_COMM_WORLD ${{steps.file_changes.outputs.files}}; + if grep MPI_COMM_WORLD ${{steps.file_changes.outputs.files}}; then echo "The following changed files contain MPI_COMM_WORLD, which is not allowed:" grep MPI_COMM_WORLD ${{steps.file_changes.outputs.files}} || true exit 1 + else + echo "MPI_COMM_WORLD not found; PASS fi From 4b59cb396d004452d6eaae5b3bf75fc16f44f2ba Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Mon, 7 Aug 2023 14:39:49 -0600 Subject: [PATCH 10/28] Update probited-strings.yml --- .github/workflows/probited-strings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/probited-strings.yml b/.github/workflows/probited-strings.yml index 8869a6673d3f..81ba8193bb28 100644 --- a/.github/workflows/probited-strings.yml +++ b/.github/workflows/probited-strings.yml @@ -48,5 +48,5 @@ jobs: grep MPI_COMM_WORLD ${{steps.file_changes.outputs.files}} || true exit 1 else - echo "MPI_COMM_WORLD not found; PASS + echo "MPI_COMM_WORLD not found; PASS" fi From 33f8e636032c86beefecc4a957f8d21f3ef11120 Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Mon, 7 Aug 2023 14:41:58 -0600 Subject: [PATCH 11/28] Update probited-strings.yml --- .github/workflows/probited-strings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/probited-strings.yml b/.github/workflows/probited-strings.yml index 81ba8193bb28..5535f422f71f 100644 --- a/.github/workflows/probited-strings.yml +++ b/.github/workflows/probited-strings.yml @@ -45,7 +45,7 @@ jobs: if grep MPI_COMM_WORLD ${{steps.file_changes.outputs.files}}; then echo "The following changed files contain MPI_COMM_WORLD, which is not allowed:" - grep MPI_COMM_WORLD ${{steps.file_changes.outputs.files}} || true + grep -l MPI_COMM_WORLD ${{steps.file_changes.outputs.files}} || true exit 1 else echo "MPI_COMM_WORLD not found; PASS" From b27327d0a203fed56ac94c11fef775a9dcd9d3bb Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Mon, 7 Aug 2023 14:42:50 -0600 Subject: [PATCH 12/28] Update probited-strings.yml --- .github/workflows/probited-strings.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/probited-strings.yml b/.github/workflows/probited-strings.yml index 5535f422f71f..b0e55927a478 100644 --- a/.github/workflows/probited-strings.yml +++ b/.github/workflows/probited-strings.yml @@ -42,10 +42,10 @@ jobs: # This step uses the `run` command to execute a script that is stored in the repository at `script/rendered-content-link-checker.mjs` and passes all the parameters it needs to run. - name: Find illegal MPI_COMM_WORLD strings run: | - if grep MPI_COMM_WORLD ${{steps.file_changes.outputs.files}}; + files=$(grep -l MPI_COMM_WORLD ${{steps.file_changes.outputs.files}}) + if ${files}; then - echo "The following changed files contain MPI_COMM_WORLD, which is not allowed:" - grep -l MPI_COMM_WORLD ${{steps.file_changes.outputs.files}} || true + echo -e "The following changed files contain MPI_COMM_WORLD, which is not allowed:\n${files}" exit 1 else echo "MPI_COMM_WORLD not found; PASS" From 103c847091ff114a1452f02516273dad73acfef2 Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Mon, 7 Aug 2023 14:44:09 -0600 Subject: [PATCH 13/28] Update probited-strings.yml --- .github/workflows/probited-strings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/probited-strings.yml b/.github/workflows/probited-strings.yml index b0e55927a478..1db0eb47a6ca 100644 --- a/.github/workflows/probited-strings.yml +++ b/.github/workflows/probited-strings.yml @@ -43,7 +43,7 @@ jobs: - name: Find illegal MPI_COMM_WORLD strings run: | files=$(grep -l MPI_COMM_WORLD ${{steps.file_changes.outputs.files}}) - if ${files}; + if [ -n ${files} ] then echo -e "The following changed files contain MPI_COMM_WORLD, which is not allowed:\n${files}" exit 1 From 78f7db5d649d9f78d71c484f733e0b95c4d9a890 Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Mon, 7 Aug 2023 14:46:03 -0600 Subject: [PATCH 14/28] Update probited-strings.yml --- .github/workflows/probited-strings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/probited-strings.yml b/.github/workflows/probited-strings.yml index 1db0eb47a6ca..2c741f5e00c0 100644 --- a/.github/workflows/probited-strings.yml +++ b/.github/workflows/probited-strings.yml @@ -43,7 +43,7 @@ jobs: - name: Find illegal MPI_COMM_WORLD strings run: | files=$(grep -l MPI_COMM_WORLD ${{steps.file_changes.outputs.files}}) - if [ -n ${files} ] + if [ -n "${files}" ] then echo -e "The following changed files contain MPI_COMM_WORLD, which is not allowed:\n${files}" exit 1 From 735f7bf272b3db29e9a559ee17894b2329c790df Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Mon, 7 Aug 2023 14:52:34 -0600 Subject: [PATCH 15/28] Update probited-strings.yml --- .github/workflows/probited-strings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/probited-strings.yml b/.github/workflows/probited-strings.yml index 2c741f5e00c0..15ca99529202 100644 --- a/.github/workflows/probited-strings.yml +++ b/.github/workflows/probited-strings.yml @@ -42,7 +42,7 @@ jobs: # This step uses the `run` command to execute a script that is stored in the repository at `script/rendered-content-link-checker.mjs` and passes all the parameters it needs to run. - name: Find illegal MPI_COMM_WORLD strings run: | - files=$(grep -l MPI_COMM_WORLD ${{steps.file_changes.outputs.files}}) + files=$(grep -l packages/ ${{steps.file_changes.outputs.files}} | grep -l MPI_COMM_WORLD) if [ -n "${files}" ] then echo -e "The following changed files contain MPI_COMM_WORLD, which is not allowed:\n${files}" From 35defff72706bb6206d6e03f38322c35254c4d90 Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Mon, 7 Aug 2023 14:53:15 -0600 Subject: [PATCH 16/28] Add/move testing files --- mybadfile => mygoodfile | 0 packages/mybadfile | 1 + 2 files changed, 1 insertion(+) rename mybadfile => mygoodfile (100%) create mode 100644 packages/mybadfile diff --git a/mybadfile b/mygoodfile similarity index 100% rename from mybadfile rename to mygoodfile diff --git a/packages/mybadfile b/packages/mybadfile new file mode 100644 index 000000000000..849bfda8ac96 --- /dev/null +++ b/packages/mybadfile @@ -0,0 +1 @@ +MPI_COMM_WORLD() From 1b91f0e6bb280884ce05f44d9ef98e89b20c6391 Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Mon, 7 Aug 2023 15:16:10 -0600 Subject: [PATCH 17/28] Update probited-strings.yml --- .github/workflows/probited-strings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/probited-strings.yml b/.github/workflows/probited-strings.yml index 15ca99529202..e821b5c80965 100644 --- a/.github/workflows/probited-strings.yml +++ b/.github/workflows/probited-strings.yml @@ -42,7 +42,7 @@ jobs: # This step uses the `run` command to execute a script that is stored in the repository at `script/rendered-content-link-checker.mjs` and passes all the parameters it needs to run. - name: Find illegal MPI_COMM_WORLD strings run: | - files=$(grep -l packages/ ${{steps.file_changes.outputs.files}} | grep -l MPI_COMM_WORLD) + files=$(grep -l MPI_COMM_WORLD ${{steps.file_changes.outputs.files}} | grep packages/) if [ -n "${files}" ] then echo -e "The following changed files contain MPI_COMM_WORLD, which is not allowed:\n${files}" From 63a80915c6831b0f778674bf4712cba63b0e76c7 Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Mon, 7 Aug 2023 15:19:13 -0600 Subject: [PATCH 18/28] Update probited-strings.yml --- .github/workflows/probited-strings.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/probited-strings.yml b/.github/workflows/probited-strings.yml index e821b5c80965..c0c91f8cce38 100644 --- a/.github/workflows/probited-strings.yml +++ b/.github/workflows/probited-strings.yml @@ -45,7 +45,10 @@ jobs: files=$(grep -l MPI_COMM_WORLD ${{steps.file_changes.outputs.files}} | grep packages/) if [ -n "${files}" ] then - echo -e "The following changed files contain MPI_COMM_WORLD, which is not allowed:\n${files}" + echo -e "\n#########################################################################" + echo -e "The following changed files contain MPI_COMM_WORLD, which is not allowed:" + echo -e "${files}" + echo -e "#########################################################################" exit 1 else echo "MPI_COMM_WORLD not found; PASS" From 24627e4ca0186508826dac122cb4e92cff68b91b Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Tue, 8 Aug 2023 07:04:40 -0600 Subject: [PATCH 19/28] Update probited-strings.yml --- .github/workflows/probited-strings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/probited-strings.yml b/.github/workflows/probited-strings.yml index c0c91f8cce38..b3751adf68b6 100644 --- a/.github/workflows/probited-strings.yml +++ b/.github/workflows/probited-strings.yml @@ -46,7 +46,7 @@ jobs: if [ -n "${files}" ] then echo -e "\n#########################################################################" - echo -e "The following changed files contain MPI_COMM_WORLD, which is not allowed:" + echo -e "The following changed files contain MPI_COMM_WORLD, which is not allowed (xSDK policy M3):" echo -e "${files}" echo -e "#########################################################################" exit 1 From 977172dccff6d9e2a26f5ac9d2b0c442a7268503 Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Tue, 8 Aug 2023 07:12:58 -0600 Subject: [PATCH 20/28] Update probited-strings.yml --- .github/workflows/probited-strings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/probited-strings.yml b/.github/workflows/probited-strings.yml index b3751adf68b6..05987cb59075 100644 --- a/.github/workflows/probited-strings.yml +++ b/.github/workflows/probited-strings.yml @@ -30,7 +30,7 @@ jobs: # # In this example, this step creates the file "${{ env.HOME }}/files.json", among others. - id: file_changes - uses: trilom/file-changes-action@a6ca26c14274c33b15e6499323aac178af06ad4b + uses: trilom/file-changes-action@v1.2.4 with: output: ' ' fileOutput: ' ' From 4b7a23f38b8aa249f9fdb5a388f150d086a71784 Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Thu, 10 Aug 2023 08:20:12 -0600 Subject: [PATCH 21/28] Update probited-strings.yml --- .github/workflows/probited-strings.yml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/.github/workflows/probited-strings.yml b/.github/workflows/probited-strings.yml index 05987cb59075..ed7e1acd9ad7 100644 --- a/.github/workflows/probited-strings.yml +++ b/.github/workflows/probited-strings.yml @@ -1,45 +1,28 @@ -# This defines the name of the workflow as it will appear in the "Actions" tab of the GitHub repository. name: 'Prohibited Strings' -# The `on` key lets you define the events that trigger when the workflow is run. You can define multiple events here. For more information, see "[AUTOTITLE](/actions/using-workflows/triggering-a-workflow#using-events-to-trigger-workflows)." on: -# Add the `workflow_dispatch` event if you want to be able to manually run this workflow from the UI. For more information, see [`workflow_dispatch`](/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch). workflow_dispatch: - # Add the `push` event, so that the workflow runs automatically every time a commit is pushed to a branch called `main`. For more information, see [`push`](/actions/using-workflows/events-that-trigger-workflows#push). - # Add the `pull_request` event, so that the workflow runs automatically every time a pull request is created or updated. For more information, see [`pull_request`](/actions/using-workflows/events-that-trigger-workflows#pull_request). pull_request: branches: - 'develop' - 'master' -# The `jobs` key groups together all the jobs that run in the workflow file. jobs: - # This line defines a job with the ID `check-links` that is stored within the `jobs` key. mpi_comm_world: - # The `runs-on` key in this example configures the job to run on a GitHub-hosted runner or a self-hosted runner, depending on the repository running the workflow. - # - # In this example, the job will run on a self-hosted runner if the repository is named `docs-internal` and is within the `github` organization. If the repository doesn't match this path, then it will run on an `ubuntu-latest` runner hosted by GitHub. For more information on these options, see "[AUTOTITLE](/actions/using-jobs/choosing-the-runner-for-a-job)." runs-on: ubuntu-latest - # The `steps` key groups together all the steps that will run as part of the `check-links` job. Each job in a workflow has its own `steps` section. steps: - # The `uses` key tells the job to retrieve the action named `actions/checkout`. This is an action that checks out your repository and downloads it to the runner, allowing you to run actions against your code (such as testing tools). You must use the checkout action any time your workflow will use the repository's code or you are using an action defined in the repository. - name: Checkout uses: actions/checkout@v3 - # This step uses the `trilom/file-changes-action` action to gather all the changed files. This example is pinned to a specific version of the action, using the `a6ca26c14274c33b15e6499323aac178af06ad4b` SHA. - # - # In this example, this step creates the file "${{ env.HOME }}/files.json", among others. - id: file_changes uses: trilom/file-changes-action@v1.2.4 with: output: ' ' fileOutput: ' ' - # To help with verification, this step lists the contents of `files.json`. This will be visible in the workflow run's log, and can be useful for debugging. - name: Show files changed run: echo '${{ steps.file_changes.outputs.files}}' - # This step uses the `run` command to execute a script that is stored in the repository at `script/rendered-content-link-checker.mjs` and passes all the parameters it needs to run. - name: Find illegal MPI_COMM_WORLD strings run: | files=$(grep -l MPI_COMM_WORLD ${{steps.file_changes.outputs.files}} | grep packages/) From 8179fdb7ed3aae27d3aefad9fda17fb83a7e0469 Mon Sep 17 00:00:00 2001 From: Jacob Domagala Date: Fri, 18 Aug 2023 21:28:30 +0200 Subject: [PATCH 22/28] Framework: Create GitHub action check for detecting addition of MPI_COMM_WORLD --- .github/workflows/detect-mpi-comm-world.yml | 20 +++ .../utilities/check-mpi-comm-world-usage.py | 131 ++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 .github/workflows/detect-mpi-comm-world.yml create mode 100644 commonTools/test/utilities/check-mpi-comm-world-usage.py diff --git a/.github/workflows/detect-mpi-comm-world.yml b/.github/workflows/detect-mpi-comm-world.yml new file mode 100644 index 000000000000..8ee7180ef044 --- /dev/null +++ b/.github/workflows/detect-mpi-comm-world.yml @@ -0,0 +1,20 @@ +name: Check MPI_COMM_WORLD + +on: + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Search for MPI_COMM_WORLD in modified lines + run: | + python $GITHUB_WORKSPACE/commonTools/test/utilities/check-mpi-comm-world-usage.py \ + --base origin/${{ github.event.pull_request.base.ref }} \ + --head ${{ github.event.pull_request.head.sha }} diff --git a/commonTools/test/utilities/check-mpi-comm-world-usage.py b/commonTools/test/utilities/check-mpi-comm-world-usage.py new file mode 100644 index 000000000000..81a6776f7d3d --- /dev/null +++ b/commonTools/test/utilities/check-mpi-comm-world-usage.py @@ -0,0 +1,131 @@ +import sys +import subprocess +import re +import argparse + + +def parse_diff_output(changed_files): + # Regex to capture filename and the line numbers of the changes + file_pattern = re.compile(r"^\+\+\+ b/(.*?)$", re.MULTILINE) + line_pattern = re.compile(r"^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@", re.MULTILINE) + + files = {} + for match in file_pattern.finditer(changed_files): + file_name = match.group(1) + + # Filtering for C/C++ files and excluding certain directories + if file_name.endswith((".c", ".cpp", ".h", ".hpp")) and all( + excluded not in file_name + for excluded in [ + "doc/", + "test_utils/", + "test/", + "tests/", + "unit_test", + "perf_test", + "example/", + "examples/", + ] + ): + # Find the lines that changed for this file + lines_start_at = match.end() + next_file_match = file_pattern.search(changed_files, pos=match.span(0)[1]) + + # Slice out the part of the diff that pertains to this file + file_diff = changed_files[ + lines_start_at : next_file_match.span(0)[0] if next_file_match else None + ] + + # Extract line numbers of the changes + changed_lines = [] + for line_match in line_pattern.finditer(file_diff): + start_line = int(line_match.group(1)) + num_lines = int(line_match.group(2) or 1) + + # The start and end positions for this chunk of diff + chunk_start = line_match.end() + next_chunk = line_pattern.search(file_diff, pos=line_match.span(0)[1]) + chunk_diff = file_diff[ + chunk_start : next_chunk.span(0)[0] if next_chunk else None + ] + + lines = chunk_diff.splitlines() + line_counter = 0 + for line in lines: + if line.startswith("+"): + line_counter += 1 + if ( + "MPI_COMM_WORLD" in line + and not "CHECK: ALLOW MPI_COMM_WORLD" in line + ): + # Only include lines where "MPI_COMM_WORLD" is added + # and "CHECK: ALLOW MPI_COMM_WORLD" is not present + changed_lines.append(start_line + line_counter) + + if changed_lines: + files[file_name] = changed_lines + + return files + + +def get_changed_files_uncommitted(): + """Get a dictionary of files and their changed lines where MPI_COMM_WORLD was added from uncommitted changes.""" + cmd = ["git", "diff", "-U0", "--ignore-all-space", "HEAD"] + result = subprocess.check_output(cmd).decode("utf-8") + + return parse_diff_output(result) + + +def get_changed_files(start_commit, end_commit): + """Get a dictionary of files and their changed lines between two commits where MPI_COMM_WORLD was added.""" + cmd = ["git", "diff", "-U0", "--ignore-all-space", start_commit, end_commit] + result = subprocess.check_output(cmd).decode("utf-8") + + return parse_diff_output(result) + + +def print_occurences(changed_files, title): + print(title) + for file_name, lines in changed_files.items(): + print("-----") + print(f"File: {file_name}") + print("Changed Lines:", ", ".join(map(str, lines))) + print("-----") + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + + parser.add_argument( + "--base", default="origin/develop", help="BASE commit (default: %(default)s)" + ) + parser.add_argument( + "--head", default="HEAD", help="HEAD commit (default: %(default)s)" + ) + + start_commit = parser.parse_args().base + print(f"Start commit: {start_commit}") + + end_commit = parser.parse_args().head + print(f"End commit: {end_commit}") + + commited_occurences = get_changed_files(start_commit, end_commit) + uncommited_occurences = get_changed_files_uncommitted() + + mpi_comm_world_detected = commited_occurences or uncommited_occurences + + if mpi_comm_world_detected: + if commited_occurences: + print_occurences( + commited_occurences, "Detected MPI_COMM_WORLD in the following files:" + ) + if uncommited_occurences: + print_occurences( + uncommited_occurences, + "Detected MPI_COMM_WORLD in the following files (uncommited changes):", + ) + + sys.exit(1) # Exit with an error code to fail the GitHub Action + else: + print("No addition of MPI_COMM_WORLD detected.") + sys.exit(0) From 7d218f31d766b5d68fa9d158f3e2be6da580ba2e Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Wed, 23 Aug 2023 15:23:22 -0600 Subject: [PATCH 23/28] Delete probited-strings.yml --- .github/workflows/probited-strings.yml | 38 -------------------------- 1 file changed, 38 deletions(-) delete mode 100644 .github/workflows/probited-strings.yml diff --git a/.github/workflows/probited-strings.yml b/.github/workflows/probited-strings.yml deleted file mode 100644 index ed7e1acd9ad7..000000000000 --- a/.github/workflows/probited-strings.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: 'Prohibited Strings' - -on: - workflow_dispatch: - pull_request: - branches: - - 'develop' - - 'master' - -jobs: - mpi_comm_world: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - id: file_changes - uses: trilom/file-changes-action@v1.2.4 - with: - output: ' ' - fileOutput: ' ' - - - name: Show files changed - run: echo '${{ steps.file_changes.outputs.files}}' - - - name: Find illegal MPI_COMM_WORLD strings - run: | - files=$(grep -l MPI_COMM_WORLD ${{steps.file_changes.outputs.files}} | grep packages/) - if [ -n "${files}" ] - then - echo -e "\n#########################################################################" - echo -e "The following changed files contain MPI_COMM_WORLD, which is not allowed (xSDK policy M3):" - echo -e "${files}" - echo -e "#########################################################################" - exit 1 - else - echo "MPI_COMM_WORLD not found; PASS" - fi From 9ffd64d717f4aa6fa9360a85227610e4345c9ef8 Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Wed, 23 Aug 2023 15:23:39 -0600 Subject: [PATCH 24/28] Delete mygoodfile --- mygoodfile | 1 - 1 file changed, 1 deletion(-) delete mode 100644 mygoodfile diff --git a/mygoodfile b/mygoodfile deleted file mode 100644 index 849bfda8ac96..000000000000 --- a/mygoodfile +++ /dev/null @@ -1 +0,0 @@ -MPI_COMM_WORLD() From c7d6098d41c0f5dde71efcd8c1a4114c1bb036bd Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Wed, 23 Aug 2023 15:24:05 -0600 Subject: [PATCH 25/28] Rename check to be 'codestyle' --- .github/workflows/detect-mpi-comm-world.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/detect-mpi-comm-world.yml b/.github/workflows/detect-mpi-comm-world.yml index 8ee7180ef044..7585bf16b973 100644 --- a/.github/workflows/detect-mpi-comm-world.yml +++ b/.github/workflows/detect-mpi-comm-world.yml @@ -4,7 +4,7 @@ on: pull_request: jobs: - build: + codestyle: runs-on: ubuntu-latest steps: From 31fd02553d9a0080fbe24be3f0324f3584257208 Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Wed, 23 Aug 2023 15:31:17 -0600 Subject: [PATCH 26/28] Rename mybadfile to mybadfile.c --- packages/{mybadfile => mybadfile.c} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/{mybadfile => mybadfile.c} (100%) diff --git a/packages/mybadfile b/packages/mybadfile.c similarity index 100% rename from packages/mybadfile rename to packages/mybadfile.c From c764db7b487660830006db485f5e19f8fda201d9 Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Wed, 23 Aug 2023 15:33:10 -0600 Subject: [PATCH 27/28] Delete mybadfile.c --- packages/mybadfile.c | 1 - 1 file changed, 1 deletion(-) delete mode 100644 packages/mybadfile.c diff --git a/packages/mybadfile.c b/packages/mybadfile.c deleted file mode 100644 index 849bfda8ac96..000000000000 --- a/packages/mybadfile.c +++ /dev/null @@ -1 +0,0 @@ -MPI_COMM_WORLD() From 561cb2e6da5b69878a865166b03d3bc0d5d94ab7 Mon Sep 17 00:00:00 2001 From: Samuel Browne Date: Wed, 23 Aug 2023 15:34:45 -0600 Subject: [PATCH 28/28] Update detect-mpi-comm-world.yml --- .github/workflows/detect-mpi-comm-world.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/detect-mpi-comm-world.yml b/.github/workflows/detect-mpi-comm-world.yml index 7585bf16b973..8ee7180ef044 100644 --- a/.github/workflows/detect-mpi-comm-world.yml +++ b/.github/workflows/detect-mpi-comm-world.yml @@ -4,7 +4,7 @@ on: pull_request: jobs: - codestyle: + build: runs-on: ubuntu-latest steps: