From be0e22f5bf3e84947d8fad78f75f94be21648a87 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 11:27:49 +0100 Subject: [PATCH 01/64] Draft new action --- .github/workflows/ci-update-mtdca.yml | 54 +++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/ci-update-mtdca.yml diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml new file mode 100644 index 00000000..0aa96607 --- /dev/null +++ b/.github/workflows/ci-update-mtdca.yml @@ -0,0 +1,54 @@ +name: Update CSV on Release + +on: + workflow_dispatch: + +jobs: + update-csv: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Fetch CSV file from target repository + run: | + # Replace `` with the username or organization name of the target repository owner + # Replace `` with the name of the target repository + # Replace `path/to/csv/file.csv` with the actual path to the CSV file in the target repository + curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "Accept: application/vnd.github.v3.raw" \ + -o dcc_config.csv \ + -L "https://raw.github + usercontent.com/adamjtaylor/data_curator_config/main/dcc_config.csv" + + - name: Modify CSV file + run: | + # Replace `path/to/csv/file.csv` with the actual path to your CSV file + # Replace `https://raw.githubusercontent.com/ncihtan/data-models/v23.6.2/HTAN.model.jsonld` with the string containing the version number to be replaced + # The pattern in the regex assumes the version number has the format `vX.Y.Z` + # If the format is different, adjust the regex pattern accordingly + sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/v[0-9.]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/$GITHUB_REF/HTAN.model.jsonld|" path/to/csv/file.csv + + - name: Commit and push changes to target repository + run: | + git config --global user.name 'GitHub Action' + git config --global user.email '<>' + + # Replace `` with the username or organization name of the target repository owner + # Replace `` with the name of the target repository + # Replace `path/to/csv/file.csv` with the actual path to the CSV file in the target repository + git remote add target_repo https://github.com/adamjtaylor/data_curator_config.git + git checkout -b update-csv + git add dcc_config.csv + git commit -m "Update CSV with release tag" + git push --set-upstream target_repo update-csv + + - name: Create pull request + uses: peter-evans/create-pull-request@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: update-csv + commit-message: "Update CSV with release tag" + title: "Update CSV with release tag" + body: "This pull request updates the CSV file with the release tag." From 7f5e7b672280a8f59e7f554be734e0af1a22c24b Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 11:30:19 +0100 Subject: [PATCH 02/64] Run on PR for testing --- .github/workflows/ci-update-mtdca.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 0aa96607..db89eec7 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -1,6 +1,7 @@ name: Update CSV on Release on: + pull_request: workflow_dispatch: jobs: From 4985bf61388ad1dcca539751132d423f4a5a3fca Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 11:32:14 +0100 Subject: [PATCH 03/64] Fix url --- .github/workflows/ci-update-mtdca.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index db89eec7..7670acf4 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -20,8 +20,7 @@ jobs: curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ -H "Accept: application/vnd.github.v3.raw" \ -o dcc_config.csv \ - -L "https://raw.github - usercontent.com/adamjtaylor/data_curator_config/main/dcc_config.csv" + -L "https://raw.githubusercontent.com/adamjtaylor/data_curator_config/main/dcc_config.csv" - name: Modify CSV file run: | From 98a995ad601d661035f6673b4714545d09c05e4c Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 11:33:11 +0100 Subject: [PATCH 04/64] Fix path --- .github/workflows/ci-update-mtdca.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 7670acf4..d75e661f 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -28,7 +28,7 @@ jobs: # Replace `https://raw.githubusercontent.com/ncihtan/data-models/v23.6.2/HTAN.model.jsonld` with the string containing the version number to be replaced # The pattern in the regex assumes the version number has the format `vX.Y.Z` # If the format is different, adjust the regex pattern accordingly - sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/v[0-9.]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/$GITHUB_REF/HTAN.model.jsonld|" path/to/csv/file.csv + sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/v[0-9.]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/$GITHUB_REF/HTAN.model.jsonld|" dcc_config.csv - name: Commit and push changes to target repository run: | From e5849eb309009672ceac2e7048386a9d4137ee5a Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 11:46:24 +0100 Subject: [PATCH 05/64] Authenticate gh --- .github/workflows/ci-update-mtdca.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index d75e661f..86a5a345 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -32,18 +32,20 @@ jobs: - name: Commit and push changes to target repository run: | - git config --global user.name 'GitHub Action' - git config --global user.email '<>' - + # Set up the GitHub token for authentication + echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token + # Replace `` with the username or organization name of the target repository owner # Replace `` with the name of the target repository - # Replace `path/to/csv/file.csv` with the actual path to the CSV file in the target repository - git remote add target_repo https://github.com/adamjtaylor/data_curator_config.git + # Replace `update-csv` with the name of the branch you want to push the changes to + gh repo clone adamjtaylor/data_curator_config data_curator_config + cd data_curator_config git checkout -b update-csv + cp ..dcc_config.csv dcc_config.csv git add dcc_config.csv git commit -m "Update CSV with release tag" - git push --set-upstream target_repo update-csv - + git push --set-upstream origin update-csv + - name: Create pull request uses: peter-evans/create-pull-request@v3 with: From 6ffbb65682b78d28999cb523aa1eda64184a1ee0 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 11:47:35 +0100 Subject: [PATCH 06/64] Fix path --- .github/workflows/ci-update-mtdca.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 86a5a345..2f31762a 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -41,7 +41,7 @@ jobs: gh repo clone adamjtaylor/data_curator_config data_curator_config cd data_curator_config git checkout -b update-csv - cp ..dcc_config.csv dcc_config.csv + cp ../dcc_config.csv dcc_config.csv git add dcc_config.csv git commit -m "Update CSV with release tag" git push --set-upstream origin update-csv From 6f955fc5477c285b8dfe6e3e5247b057b395f419 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 11:49:05 +0100 Subject: [PATCH 07/64] Add git config user details --- .github/workflows/ci-update-mtdca.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 2f31762a..678366e4 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -34,7 +34,8 @@ jobs: run: | # Set up the GitHub token for authentication echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token - + git config --global user.email "adam.taylor@sagebase.org" + git config --global user.name "Adam Taylor" # Replace `` with the username or organization name of the target repository owner # Replace `` with the name of the target repository # Replace `update-csv` with the name of the branch you want to push the changes to From ec6ef5b3642d45436a9339d4cdcdcd8aa58a69ad Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 11:57:03 +0100 Subject: [PATCH 08/64] Refine git auth --- .github/workflows/ci-update-mtdca.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 678366e4..da431d22 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -33,7 +33,7 @@ jobs: - name: Commit and push changes to target repository run: | # Set up the GitHub token for authentication - echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token + git config --global credential.helper store git config --global user.email "adam.taylor@sagebase.org" git config --global user.name "Adam Taylor" # Replace `` with the username or organization name of the target repository owner @@ -45,7 +45,7 @@ jobs: cp ../dcc_config.csv dcc_config.csv git add dcc_config.csv git commit -m "Update CSV with release tag" - git push --set-upstream origin update-csv + git push --set-upstream origin update-csv -u "adamjtaylor:${{ secrets.GITHUB_TOKEN }}" - name: Create pull request uses: peter-evans/create-pull-request@v3 From 05168d5945a1bd32e223047af35bd06777a01a35 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 11:59:14 +0100 Subject: [PATCH 09/64] Use git clone --- .github/workflows/ci-update-mtdca.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index da431d22..ad677ccc 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -39,7 +39,7 @@ jobs: # Replace `` with the username or organization name of the target repository owner # Replace `` with the name of the target repository # Replace `update-csv` with the name of the branch you want to push the changes to - gh repo clone adamjtaylor/data_curator_config data_curator_config + git clone https://github.com/adamjtaylor/data_curator_config data_curator_config cd data_curator_config git checkout -b update-csv cp ../dcc_config.csv dcc_config.csv From 5a4e1026ab5847fc77673ae1aea4c01919d821c2 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 12:00:58 +0100 Subject: [PATCH 10/64] Refine git clone --- .github/workflows/ci-update-mtdca.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index ad677ccc..fdca6c43 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -39,7 +39,7 @@ jobs: # Replace `` with the username or organization name of the target repository owner # Replace `` with the name of the target repository # Replace `update-csv` with the name of the branch you want to push the changes to - git clone https://github.com/adamjtaylor/data_curator_config data_curator_config + git clone https://github.com/adamjtaylor/data_curator_config.git cd data_curator_config git checkout -b update-csv cp ../dcc_config.csv dcc_config.csv From 7fc34e1e711e3ef03f11fe4ee993b5d024ec5ca7 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 12:08:27 +0100 Subject: [PATCH 11/64] Use DCA config pat --- .github/workflows/ci-update-mtdca.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index fdca6c43..69d0919e 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -45,7 +45,7 @@ jobs: cp ../dcc_config.csv dcc_config.csv git add dcc_config.csv git commit -m "Update CSV with release tag" - git push --set-upstream origin update-csv -u "adamjtaylor:${{ secrets.GITHUB_TOKEN }}" + git push --set-upstream origin update-csv -u "adamjtaylor:${{ secrets.DCA_CONFIG_PAT }}" - name: Create pull request uses: peter-evans/create-pull-request@v3 From 10cb7b728c3aaeaf51df187c073c8359416ab18c Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 12:11:27 +0100 Subject: [PATCH 12/64] Push without authentication --- .github/workflows/ci-update-mtdca.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 69d0919e..795d451b 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -45,7 +45,7 @@ jobs: cp ../dcc_config.csv dcc_config.csv git add dcc_config.csv git commit -m "Update CSV with release tag" - git push --set-upstream origin update-csv -u "adamjtaylor:${{ secrets.DCA_CONFIG_PAT }}" + git push --set-upstream origin update-csvs - name: Create pull request uses: peter-evans/create-pull-request@v3 From 47c42e0cd3732ac9c323b254674ad15b9d67070b Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 12:12:30 +0100 Subject: [PATCH 13/64] Correct branch name --- .github/workflows/ci-update-mtdca.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 795d451b..5e5891b6 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -45,7 +45,7 @@ jobs: cp ../dcc_config.csv dcc_config.csv git add dcc_config.csv git commit -m "Update CSV with release tag" - git push --set-upstream origin update-csvs + git push --set-upstream origin update-csv - name: Create pull request uses: peter-evans/create-pull-request@v3 From b81b105aeac64678dab1eb73c0f17a2276b70828 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 12:14:14 +0100 Subject: [PATCH 14/64] Try auth again --- .github/workflows/ci-update-mtdca.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 5e5891b6..a8b3f4cb 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -45,6 +45,7 @@ jobs: cp ../dcc_config.csv dcc_config.csv git add dcc_config.csv git commit -m "Update CSV with release tag" + git remote set-url origin "https://${{ secrets.DCA_CONFIG_PAT }}@github.com/adamjtaylor/data_curator_config.git" git push --set-upstream origin update-csv - name: Create pull request From 9015c4f4c962bb2945aed37f7e3e5607302e633d Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 12:21:57 +0100 Subject: [PATCH 15/64] Use ${{ github.ref }} in sed --- .github/workflows/ci-update-mtdca.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index a8b3f4cb..6d2c47c0 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -28,7 +28,7 @@ jobs: # Replace `https://raw.githubusercontent.com/ncihtan/data-models/v23.6.2/HTAN.model.jsonld` with the string containing the version number to be replaced # The pattern in the regex assumes the version number has the format `vX.Y.Z` # If the format is different, adjust the regex pattern accordingly - sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/v[0-9.]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/$GITHUB_REF/HTAN.model.jsonld|" dcc_config.csv + sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/v[0-9.]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/${{ github.ref }}/HTAN.model.jsonld|" dcc_config.csv - name: Commit and push changes to target repository run: | From b89eddceab5fbedea15005569066e5846eb97a59 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 12:25:59 +0100 Subject: [PATCH 16/64] Use event.ref --- .github/workflows/ci-update-mtdca.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 6d2c47c0..c6b6f71e 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -28,7 +28,7 @@ jobs: # Replace `https://raw.githubusercontent.com/ncihtan/data-models/v23.6.2/HTAN.model.jsonld` with the string containing the version number to be replaced # The pattern in the regex assumes the version number has the format `vX.Y.Z` # If the format is different, adjust the regex pattern accordingly - sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/v[0-9.]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/${{ github.ref }}/HTAN.model.jsonld|" dcc_config.csv + sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/v[0-9.]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/${{ github.event.ref }}/HTAN.model.jsonld|" dcc_config.csv - name: Commit and push changes to target repository run: | From 5b02c59d8ae7aeabd0b2bead984171d75a64b81a Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 12:29:21 +0100 Subject: [PATCH 17/64] Use comit if tag not avaliable --- .github/workflows/ci-update-mtdca.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index c6b6f71e..f92afa8a 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -28,8 +28,11 @@ jobs: # Replace `https://raw.githubusercontent.com/ncihtan/data-models/v23.6.2/HTAN.model.jsonld` with the string containing the version number to be replaced # The pattern in the regex assumes the version number has the format `vX.Y.Z` # If the format is different, adjust the regex pattern accordingly - sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/v[0-9.]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/${{ github.event.ref }}/HTAN.model.jsonld|" dcc_config.csv - + if [[ -n "${{ github.event.ref }}" ]]; then + sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/v[0-9.]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/${{ github.event.ref }}/HTAN.model.jsonld|" dcc_config.csv + else + sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/v[0-9.]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/${{ github.sha }}/HTAN.model.jsonld|" dcc_config.csv + fi - name: Commit and push changes to target repository run: | # Set up the GitHub token for authentication From 0e6c800c7267c84972110de8de5ec73be966b695 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 12:32:27 +0100 Subject: [PATCH 18/64] Don't be strict on version format --- .github/workflows/ci-update-mtdca.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index f92afa8a..c0a2ec44 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -29,9 +29,9 @@ jobs: # The pattern in the regex assumes the version number has the format `vX.Y.Z` # If the format is different, adjust the regex pattern accordingly if [[ -n "${{ github.event.ref }}" ]]; then - sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/v[0-9.]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/${{ github.event.ref }}/HTAN.model.jsonld|" dcc_config.csv + sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/[^/]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/${{ github.event.ref }}/HTAN.model.jsonld|" dcc_config.csv else - sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/v[0-9.]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/${{ github.sha }}/HTAN.model.jsonld|" dcc_config.csv + sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/[^/]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/${{ github.sha }}/HTAN.model.jsonld|" dcc_config.csv fi - name: Commit and push changes to target repository run: | From ab9f1626960a77f0b376063eac321ee93f40c5c1 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 12:39:16 +0100 Subject: [PATCH 19/64] Use curl for PR --- .github/workflows/ci-update-mtdca.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index c0a2ec44..1aa1803d 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -52,10 +52,14 @@ jobs: git push --set-upstream origin update-csv - name: Create pull request - uses: peter-evans/create-pull-request@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - branch: update-csv - commit-message: "Update CSV with release tag" - title: "Update CSV with release tag" - body: "This pull request updates the CSV file with the release tag." + run: | + curl -X POST \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + "https://api.github.com/repos/adamjtaylor/data_curator_config/pulls" \ + -d "{ + \"title\": \"Updae CSV with release tag\", + \"head\": \"update-csv\", + \"base\": \"main\", + \"body\": \"This pull request updates the CSV file with the release tag.\" + }" From f12bcef5c2fa9c5a837ecce7a0bc972fd552818a Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 12:40:31 +0100 Subject: [PATCH 20/64] Use DCA config pat for PR --- .github/workflows/ci-update-mtdca.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 1aa1803d..9952eb4b 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -54,7 +54,7 @@ jobs: - name: Create pull request run: | curl -X POST \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "Authorization: Bearer ${{ secrets.DCA_CONFIG_PAT }}" \ -H "Accept: application/vnd.github.v3+json" \ "https://api.github.com/repos/adamjtaylor/data_curator_config/pulls" \ -d "{ From c1687fc88c89d3cfc75ebb63bdc3cd659b8e89ca Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 12:45:13 +0100 Subject: [PATCH 21/64] Make branch unique --- .github/workflows/ci-update-mtdca.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 9952eb4b..63e29283 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -44,12 +44,12 @@ jobs: # Replace `update-csv` with the name of the branch you want to push the changes to git clone https://github.com/adamjtaylor/data_curator_config.git cd data_curator_config - git checkout -b update-csv + git checkout -b update-csv-${{ GITHUB_SHA::7}} cp ../dcc_config.csv dcc_config.csv git add dcc_config.csv git commit -m "Update CSV with release tag" git remote set-url origin "https://${{ secrets.DCA_CONFIG_PAT }}@github.com/adamjtaylor/data_curator_config.git" - git push --set-upstream origin update-csv + git push --set-upstream origin update-csv-${{ GITHUB_SHA::7}} - name: Create pull request run: | @@ -59,7 +59,8 @@ jobs: "https://api.github.com/repos/adamjtaylor/data_curator_config/pulls" \ -d "{ \"title\": \"Updae CSV with release tag\", - \"head\": \"update-csv\", + \"head\": \"update-csv-${{ GITHUB_SHA::7}}\", \"base\": \"main\", - \"body\": \"This pull request updates the CSV file with the release tag.\" + \"body\": \"This pull request updates the CSV file with the release tag.\", + \"draft\": true, }" From f41e86ea4fc9f015c670157cc34754019c202a19 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 12:46:49 +0100 Subject: [PATCH 22/64] Fix short sha --- .github/workflows/ci-update-mtdca.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 63e29283..6d0bc08a 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -44,12 +44,12 @@ jobs: # Replace `update-csv` with the name of the branch you want to push the changes to git clone https://github.com/adamjtaylor/data_curator_config.git cd data_curator_config - git checkout -b update-csv-${{ GITHUB_SHA::7}} + git checkout -b update-csv-${{ github.sha | slice(0, 7) }} cp ../dcc_config.csv dcc_config.csv git add dcc_config.csv git commit -m "Update CSV with release tag" git remote set-url origin "https://${{ secrets.DCA_CONFIG_PAT }}@github.com/adamjtaylor/data_curator_config.git" - git push --set-upstream origin update-csv-${{ GITHUB_SHA::7}} + git push --set-upstream origin update-csv-${{ github.sha | slice(0, 7) }} - name: Create pull request run: | @@ -59,7 +59,7 @@ jobs: "https://api.github.com/repos/adamjtaylor/data_curator_config/pulls" \ -d "{ \"title\": \"Updae CSV with release tag\", - \"head\": \"update-csv-${{ GITHUB_SHA::7}}\", + \"head\": \"update-csv-${{ github.sha | slice(0, 7) }}\", \"base\": \"main\", \"body\": \"This pull request updates the CSV file with the release tag.\", \"draft\": true, From 2c3198fc13913270962f40358d0f3e53a40ad82d Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 12:51:34 +0100 Subject: [PATCH 23/64] Use long sha in branchname --- .github/workflows/ci-update-mtdca.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 6d0bc08a..575c895c 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -44,12 +44,12 @@ jobs: # Replace `update-csv` with the name of the branch you want to push the changes to git clone https://github.com/adamjtaylor/data_curator_config.git cd data_curator_config - git checkout -b update-csv-${{ github.sha | slice(0, 7) }} + git checkout -b update-csv-${{ github.sha }} cp ../dcc_config.csv dcc_config.csv git add dcc_config.csv git commit -m "Update CSV with release tag" git remote set-url origin "https://${{ secrets.DCA_CONFIG_PAT }}@github.com/adamjtaylor/data_curator_config.git" - git push --set-upstream origin update-csv-${{ github.sha | slice(0, 7) }} + git push --set-upstream origin update-csv-${{ github.sha }} - name: Create pull request run: | @@ -59,7 +59,7 @@ jobs: "https://api.github.com/repos/adamjtaylor/data_curator_config/pulls" \ -d "{ \"title\": \"Updae CSV with release tag\", - \"head\": \"update-csv-${{ github.sha | slice(0, 7) }}\", + \"head\": \"update-csv-${{ github.sha }}\", \"base\": \"main\", \"body\": \"This pull request updates the CSV file with the release tag.\", \"draft\": true, From 212ae73027c04ca4fb15f78097a787a1f350b7d0 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 12:54:17 +0100 Subject: [PATCH 24/64] Use short sha --- .github/workflows/ci-update-mtdca.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 575c895c..b0dceeb5 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -44,22 +44,24 @@ jobs: # Replace `update-csv` with the name of the branch you want to push the changes to git clone https://github.com/adamjtaylor/data_curator_config.git cd data_curator_config - git checkout -b update-csv-${{ github.sha }} + short_sha=$(echo "${{ github.sha }}" | cut -c 1-7) + git checkout -b update-csv-${short_sha} cp ../dcc_config.csv dcc_config.csv git add dcc_config.csv git commit -m "Update CSV with release tag" git remote set-url origin "https://${{ secrets.DCA_CONFIG_PAT }}@github.com/adamjtaylor/data_curator_config.git" - git push --set-upstream origin update-csv-${{ github.sha }} - + git push --set-upstream origin update-csv-${short_sha} + - name: Create pull request run: | + short_sha=$(echo "${{ github.sha }}" | cut -c 1-7) curl -X POST \ -H "Authorization: Bearer ${{ secrets.DCA_CONFIG_PAT }}" \ -H "Accept: application/vnd.github.v3+json" \ "https://api.github.com/repos/adamjtaylor/data_curator_config/pulls" \ -d "{ \"title\": \"Updae CSV with release tag\", - \"head\": \"update-csv-${{ github.sha }}\", + \"head\": \"update-csv-${short_sha}\", \"base\": \"main\", \"body\": \"This pull request updates the CSV file with the release tag.\", \"draft\": true, From bd9247c9852a765692b4c980f95d1726ce244887 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 12:55:36 +0100 Subject: [PATCH 25/64] Remove draft --- .github/workflows/ci-update-mtdca.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index b0dceeb5..e1cad1d4 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -51,7 +51,7 @@ jobs: git commit -m "Update CSV with release tag" git remote set-url origin "https://${{ secrets.DCA_CONFIG_PAT }}@github.com/adamjtaylor/data_curator_config.git" git push --set-upstream origin update-csv-${short_sha} - + - name: Create pull request run: | short_sha=$(echo "${{ github.sha }}" | cut -c 1-7) @@ -63,6 +63,5 @@ jobs: \"title\": \"Updae CSV with release tag\", \"head\": \"update-csv-${short_sha}\", \"base\": \"main\", - \"body\": \"This pull request updates the CSV file with the release tag.\", - \"draft\": true, + \"body\": \"This pull request updates the CSV file with the release tag.\" }" From bd47b546c062239b743356b196a8c14785d9553a Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 12:58:01 +0100 Subject: [PATCH 26/64] Update PR descriptions --- .github/workflows/ci-update-mtdca.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index e1cad1d4..4a03d572 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -60,8 +60,8 @@ jobs: -H "Accept: application/vnd.github.v3+json" \ "https://api.github.com/repos/adamjtaylor/data_curator_config/pulls" \ -d "{ - \"title\": \"Updae CSV with release tag\", + \"title\": \"Update dcc_config.csv with new data model\", \"head\": \"update-csv-${short_sha}\", \"base\": \"main\", - \"body\": \"This pull request updates the CSV file with the release tag.\" + \"body\": \"This pull request updates the CSV file with the release tag or commit sha\" }" From 4920b3367cd3ad33fab297547664ba485fa21878 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 12:59:37 +0100 Subject: [PATCH 27/64] Use draft PR --- .github/workflows/ci-update-mtdca.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 4a03d572..e6647fa1 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -63,5 +63,6 @@ jobs: \"title\": \"Update dcc_config.csv with new data model\", \"head\": \"update-csv-${short_sha}\", \"base\": \"main\", - \"body\": \"This pull request updates the CSV file with the release tag or commit sha\" + \"body\": \"This pull request updates the CSV file with the release tag or commit sha\", + \"draft\": \"true\" }" From 629532de70fe3ab673da6eb17d8cdbd303132877 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 13:04:26 +0100 Subject: [PATCH 28/64] Run on release creation --- .github/workflows/ci-update-mtdca.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index e6647fa1..c314fbc0 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -3,6 +3,8 @@ name: Update CSV on Release on: pull_request: workflow_dispatch: + release: + types: [created] jobs: update-csv: From d090670056b6210bce77ee9dd129ef662df4550a Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 13:08:06 +0100 Subject: [PATCH 29/64] Run on prereleased --- .github/workflows/ci-update-mtdca.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index c314fbc0..6b9370d4 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -4,7 +4,7 @@ on: pull_request: workflow_dispatch: release: - types: [created] + types: [prereleased] jobs: update-csv: From 3fce0e58502d4cb205982436ebb7efbf548451e5 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 13:37:52 +0100 Subject: [PATCH 30/64] Extract tag --- .github/workflows/ci-update-mtdca.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 6b9370d4..a8c0bab3 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -30,8 +30,9 @@ jobs: # Replace `https://raw.githubusercontent.com/ncihtan/data-models/v23.6.2/HTAN.model.jsonld` with the string containing the version number to be replaced # The pattern in the regex assumes the version number has the format `vX.Y.Z` # If the format is different, adjust the regex pattern accordingly - if [[ -n "${{ github.event.ref }}" ]]; then - sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/[^/]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/${{ github.event.ref }}/HTAN.model.jsonld|" dcc_config.csv + if [[ -n "${{ github.event.ref }}" && "${{ github.event.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + tag=$(echo "${{ github.event.ref }}" | awk -F '/' '{print $NF}' | sed 's/^v//') + sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/[^/]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/$tag/HTAN.model.jsonld|" dcc_config.csv else sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/[^/]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/${{ github.sha }}/HTAN.model.jsonld|" dcc_config.csv fi From 46c58c6794c48b3d96d84ad2281cfab163dd59c3 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 14:58:45 +0100 Subject: [PATCH 31/64] Use github reg_name --- .github/workflows/ci-update-mtdca.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index a8c0bab3..2187a66b 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -30,9 +30,8 @@ jobs: # Replace `https://raw.githubusercontent.com/ncihtan/data-models/v23.6.2/HTAN.model.jsonld` with the string containing the version number to be replaced # The pattern in the regex assumes the version number has the format `vX.Y.Z` # If the format is different, adjust the regex pattern accordingly - if [[ -n "${{ github.event.ref }}" && "${{ github.event.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - tag=$(echo "${{ github.event.ref }}" | awk -F '/' '{print $NF}' | sed 's/^v//') - sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/[^/]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/$tag/HTAN.model.jsonld|" dcc_config.csv + if [[ -n "${{ github.ref_name }}" ]]; then + sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/[^/]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/${{ github.ref_name }}/HTAN.model.jsonld|" dcc_config.csv else sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/[^/]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/${{ github.sha }}/HTAN.model.jsonld|" dcc_config.csv fi From 81d605904e1bcd929e2118363a4dfa61839cd66d Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 15:05:16 +0100 Subject: [PATCH 32/64] Use runid in branch name --- .github/workflows/ci-update-mtdca.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 2187a66b..32612312 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -47,12 +47,12 @@ jobs: git clone https://github.com/adamjtaylor/data_curator_config.git cd data_curator_config short_sha=$(echo "${{ github.sha }}" | cut -c 1-7) - git checkout -b update-csv-${short_sha} + git checkout -b update-csv-${{ github.run_id }}-${{ github.run_attempt }} cp ../dcc_config.csv dcc_config.csv git add dcc_config.csv git commit -m "Update CSV with release tag" git remote set-url origin "https://${{ secrets.DCA_CONFIG_PAT }}@github.com/adamjtaylor/data_curator_config.git" - git push --set-upstream origin update-csv-${short_sha} + git push --set-upstream origin update-csv-${{ github.run_id }}-${{ github.run_attempt }} - name: Create pull request run: | @@ -63,7 +63,7 @@ jobs: "https://api.github.com/repos/adamjtaylor/data_curator_config/pulls" \ -d "{ \"title\": \"Update dcc_config.csv with new data model\", - \"head\": \"update-csv-${short_sha}\", + \"head\": \"update-csv-${{ github.run_id }}-${{ github.run_attempt }}\", \"base\": \"main\", \"body\": \"This pull request updates the CSV file with the release tag or commit sha\", \"draft\": \"true\" From 00d4ee5780da0c1682a3962fe808b957dcb29ac7 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 15:09:49 +0100 Subject: [PATCH 33/64] Update if regex --- .github/workflows/ci-update-mtdca.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 32612312..9f30ccaa 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -30,7 +30,7 @@ jobs: # Replace `https://raw.githubusercontent.com/ncihtan/data-models/v23.6.2/HTAN.model.jsonld` with the string containing the version number to be replaced # The pattern in the regex assumes the version number has the format `vX.Y.Z` # If the format is different, adjust the regex pattern accordingly - if [[ -n "${{ github.ref_name }}" ]]; then + if [[ -n "${{ github.ref }}" && ! "${{ github.ref }}" == *"/"* ]]; then sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/[^/]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/${{ github.ref_name }}/HTAN.model.jsonld|" dcc_config.csv else sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/[^/]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/${{ github.sha }}/HTAN.model.jsonld|" dcc_config.csv From 6f2d3a5164e4264f9841a143f510659d6c0b112f Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 15:10:27 +0100 Subject: [PATCH 34/64] Use ref_name --- .github/workflows/ci-update-mtdca.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 9f30ccaa..aeead262 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -30,7 +30,7 @@ jobs: # Replace `https://raw.githubusercontent.com/ncihtan/data-models/v23.6.2/HTAN.model.jsonld` with the string containing the version number to be replaced # The pattern in the regex assumes the version number has the format `vX.Y.Z` # If the format is different, adjust the regex pattern accordingly - if [[ -n "${{ github.ref }}" && ! "${{ github.ref }}" == *"/"* ]]; then + if [[ -n "${{ github.ref_name }}" && ! "${{ github.ref_name }}" == *"/"* ]]; then sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/[^/]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/${{ github.ref_name }}/HTAN.model.jsonld|" dcc_config.csv else sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/[^/]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/${{ github.sha }}/HTAN.model.jsonld|" dcc_config.csv From 62a3cb25cc95eab084441510c191d071af66976b Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 15:15:11 +0100 Subject: [PATCH 35/64] Remove short sha --- .github/workflows/ci-update-mtdca.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index aeead262..3e5a6e8c 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -46,7 +46,6 @@ jobs: # Replace `update-csv` with the name of the branch you want to push the changes to git clone https://github.com/adamjtaylor/data_curator_config.git cd data_curator_config - short_sha=$(echo "${{ github.sha }}" | cut -c 1-7) git checkout -b update-csv-${{ github.run_id }}-${{ github.run_attempt }} cp ../dcc_config.csv dcc_config.csv git add dcc_config.csv @@ -56,7 +55,6 @@ jobs: - name: Create pull request run: | - short_sha=$(echo "${{ github.sha }}" | cut -c 1-7) curl -X POST \ -H "Authorization: Bearer ${{ secrets.DCA_CONFIG_PAT }}" \ -H "Accept: application/vnd.github.v3+json" \ From ea3346266b54dd8cca0e50fc42d1990d41175f6c Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 15:33:40 +0100 Subject: [PATCH 36/64] Echo replacement --- .github/workflows/ci-update-mtdca.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 3e5a6e8c..da919950 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -31,8 +31,10 @@ jobs: # The pattern in the regex assumes the version number has the format `vX.Y.Z` # If the format is different, adjust the regex pattern accordingly if [[ -n "${{ github.ref_name }}" && ! "${{ github.ref_name }}" == *"/"* ]]; then + echo "Using github.ref: ${{ github.ref_name }}" sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/[^/]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/${{ github.ref_name }}/HTAN.model.jsonld|" dcc_config.csv else + echo "Using github.sha: ${{ github.sha }}" sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/[^/]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/${{ github.sha }}/HTAN.model.jsonld|" dcc_config.csv fi - name: Commit and push changes to target repository From 14727af99ce670fd40dbb761e9a4f2a34a2d8cdf Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 19:03:37 +0100 Subject: [PATCH 37/64] Draft of make-config --- .github/workflows/ci-update-mtdca.yml | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index da919950..8a942b8f 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -7,6 +7,35 @@ on: types: [prereleased] jobs: + + + make-config: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.9' + + - name: Install Schematic + shell: bash + run: | + pip3 install poetry + git clone --single-branch --branch main https://github.com/Sage-Bionetworks/schematic.git + cd schematic + poetry build + pip3 install dist/schematicpy-*-py3-none-any.whl + + - name: Make config file from data model + shell: bash + run: | + # download the data models and create config.json + python3 .github/config_schema.py \ + -c config.yml \ + --service_repo 'Sage-Bionetworks/schematic' \ + --overwrite + update-csv: runs-on: ubuntu-latest From a841d5b2b28d104ef854aa01f1b539543187af9d Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 19:06:07 +0100 Subject: [PATCH 38/64] Move script --- .github/workflows/ci-update-mtdca.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 8a942b8f..df850a4e 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -31,13 +31,14 @@ jobs: shell: bash run: | # download the data models and create config.json - python3 .github/config_schema.py \ + python3 .github/workflows/config_schema.py \ -c config.yml \ --service_repo 'Sage-Bionetworks/schematic' \ --overwrite update-csv: runs-on: ubuntu-latest + needs: make-config steps: - name: Checkout repository From 6fb11d91f2ac41dec98fc200b7761bb2544248fa Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 19:22:37 +0100 Subject: [PATCH 39/64] Refactor config schema --- .github/workflows/config_schema.py | 92 ++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 .github/workflows/config_schema.py diff --git a/.github/workflows/config_schema.py b/.github/workflows/config_schema.py new file mode 100644 index 00000000..7bfff210 --- /dev/null +++ b/.github/workflows/config_schema.py @@ -0,0 +1,92 @@ +import argparse +import json +import os +import re +import yaml +from schematic.schemas.generator import SchemaGenerator + + +def get_args(): + """Set up command-line interface and get arguments.""" + parser = argparse.ArgumentParser() + parser.add_argument('-c', '--config_path', metavar="", + required=True, help='path to schematic config ymal file') + parser.add_argument('-sr', '--service_repo', metavar="", + help='repo path to service') + parser.add_argument('-o', '--out_dir', default='www', metavar="", + help='directory to save result') + parser.add_argument('--overwrite', action='store_true', default=False, + help='whether to overwrite the existing config.json') + return parser.parse_args() + + +def _is_valid(value, type): + if type not in ["repo", "location"]: + raise ValueError('type must be "repo" or "location"') + pattern = "^([-_.A-z0-9]+\\/){1,2}[-_.A-z0-9]+$" if type == "repo" else "^[-_.A-z0-9]+\\/.*.jsonld$" + return bool(re.match(pattern, value)) + + +def _parse_schema(config_path): + """Parse schematic_config.yml file""" + with open(config_path, "r") as stream: + try: + config = yaml.safe_load(stream)["model"]["input"] + return config + except yaml.YAMLError as exc: + print(exc) + + +def generate_schema_config(schema_path): + """Generate schema config with corresponding display name""" + schemas = [] + # get all required data types from data model jsonld + sg = SchemaGenerator(path_to_json_ld=schema_path) + component_digraph = sg.se.get_digraph_by_edge_type('requiresComponent') + components = component_digraph.nodes() + # get display names for required data types + mm_graph = sg.se.get_nx_schema() + display_names = sg.get_nodes_display_names(components, mm_graph) + # save display_name, schema_name, assay type to list + for index, component in enumerate(components): + # get component's dependencies + deps = sg.get_node_dependencies(component) + schema_type = 'file' if 'Filename' in deps else 'record' + schemas.append({ + 'display_name': display_names[index], + 'schema_name': component, + 'type': schema_type + }) + return schemas + + +def main(): + args = get_args() + # retrieve schema info from config file + config = _parse_schema(args.config_path) + + # get the location of the schema + if config.get("location") and _is_valid(config.get("location"), "location"): + schema_path = config["location"] + else: + raise ValueError(f'No valid "location" value found in "{args.config_path}" \u274C') + + if args.overwrite: + # get versions for both service and schema + service_version = _get_version(args.service_repo) + schema_version = config.get("version") or _get_version(config["repo"]) + # generate schema configuration based on *.model.jsonld + schemas_config = generate_schema_config(schema_path) + # write out the config.json including versions + config = { + 'manifest_schemas': schemas_config, + 'service_version': service_version, + 'schema_version': schema_version + } + output_path = os.path.join(args.out_dir, 'config.json') + with open(output_path, 'w') as o: + json.dump(config, o, indent=2, separators=(',', ': ')) + + +if __name__ == '__main__': + main() From 6b9134ee2af8c81986c33de61294973b77febbc1 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 19:24:09 +0100 Subject: [PATCH 40/64] Update path to script --- .github/workflows/ci-update-mtdca.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index df850a4e..565b16ce 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -30,8 +30,7 @@ jobs: - name: Make config file from data model shell: bash run: | - # download the data models and create config.json - python3 .github/workflows/config_schema.py \ + python .github/workflows/config_schema.py \ -c config.yml \ --service_repo 'Sage-Bionetworks/schematic' \ --overwrite From bb577ab82a51c194b3ad32a9d10583b4d4d3b8e6 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 19:31:28 +0100 Subject: [PATCH 41/64] Manually set some config settings --- .github/workflows/config_schema.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/config_schema.py b/.github/workflows/config_schema.py index 7bfff210..cb9a79b6 100644 --- a/.github/workflows/config_schema.py +++ b/.github/workflows/config_schema.py @@ -66,22 +66,22 @@ def main(): config = _parse_schema(args.config_path) # get the location of the schema - if config.get("location") and _is_valid(config.get("location"), "location"): - schema_path = config["location"] - else: - raise ValueError(f'No valid "location" value found in "{args.config_path}" \u274C') + #if config.get("location") and _is_valid(config.get("location"), "location"): + # schema_path = config["location"] + #else: + # raise ValueError(f'No valid "location" value found in "{args.config_path}" \u274C') if args.overwrite: # get versions for both service and schema - service_version = _get_version(args.service_repo) - schema_version = config.get("version") or _get_version(config["repo"]) + #service_version = _get_version(args.service_repo) + #schema_version = config.get("version") or _get_version(config["repo"]) # generate schema configuration based on *.model.jsonld schemas_config = generate_schema_config(schema_path) # write out the config.json including versions config = { 'manifest_schemas': schemas_config, - 'service_version': service_version, - 'schema_version': schema_version + 'service_version': '1', #service_version, + 'schema_version': '1' #schema_version } output_path = os.path.join(args.out_dir, 'config.json') with open(output_path, 'w') as o: From 34fade029d3c9c868a4a8c07224526e9ad144a2b Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 19:35:45 +0100 Subject: [PATCH 42/64] Set schema path --- .github/workflows/ci-update-mtdca.yml | 1 + .github/workflows/config_schema.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 565b16ce..e612044b 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -32,6 +32,7 @@ jobs: run: | python .github/workflows/config_schema.py \ -c config.yml \ + -s HTAN.model.jsonld \ --service_repo 'Sage-Bionetworks/schematic' \ --overwrite diff --git a/.github/workflows/config_schema.py b/.github/workflows/config_schema.py index cb9a79b6..47960447 100644 --- a/.github/workflows/config_schema.py +++ b/.github/workflows/config_schema.py @@ -11,6 +11,8 @@ def get_args(): parser = argparse.ArgumentParser() parser.add_argument('-c', '--config_path', metavar="", required=True, help='path to schematic config ymal file') + parser.add_argument('-s','--schema_path', metavar = "", + required=True, help='path to schema jsonld file') parser.add_argument('-sr', '--service_repo', metavar="", help='repo path to service') parser.add_argument('-o', '--out_dir', default='www', metavar="", @@ -67,7 +69,7 @@ def main(): # get the location of the schema #if config.get("location") and _is_valid(config.get("location"), "location"): - # schema_path = config["location"] + schema_path = args.schema_path #else: # raise ValueError(f'No valid "location" value found in "{args.config_path}" \u274C') From 81e73684ff0a5aaf30c5ddcfac1cab42a6d5d975 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 19:39:17 +0100 Subject: [PATCH 43/64] Set output dir --- .github/workflows/ci-update-mtdca.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index e612044b..623d4a10 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -33,6 +33,7 @@ jobs: python .github/workflows/config_schema.py \ -c config.yml \ -s HTAN.model.jsonld \ + -o '.' \ --service_repo 'Sage-Bionetworks/schematic' \ --overwrite From ba262f374c3191a045aa490f5fd82bfd34addd74 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 20:01:17 +0100 Subject: [PATCH 44/64] Link jobs --- .github/workflows/ci-update-mtdca.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 623d4a10..9213db49 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -37,6 +37,12 @@ jobs: --service_repo 'Sage-Bionetworks/schematic' \ --overwrite + - name: Store config.json artifact + uses: actions/upload-artifact@master + with: + name: config + path: config.json + update-csv: runs-on: ubuntu-latest needs: make-config @@ -45,6 +51,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 + - name: Fetch config.json artifact + uses: actions/download-artifact@master + with: + name: config + - name: Fetch CSV file from target repository run: | # Replace `` with the username or organization name of the target repository owner @@ -83,6 +94,8 @@ jobs: cp ../dcc_config.csv dcc_config.csv git add dcc_config.csv git commit -m "Update CSV with release tag" + git add config.json + git commit -m "Update config.json" git remote set-url origin "https://${{ secrets.DCA_CONFIG_PAT }}@github.com/adamjtaylor/data_curator_config.git" git push --set-upstream origin update-csv-${{ github.run_id }}-${{ github.run_attempt }} From a1c36a714924950c6458216121f891d491bfa4c3 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 20:04:59 +0100 Subject: [PATCH 45/64] Fix config path --- .github/workflows/ci-update-mtdca.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 9213db49..92f6b8b4 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -94,7 +94,7 @@ jobs: cp ../dcc_config.csv dcc_config.csv git add dcc_config.csv git commit -m "Update CSV with release tag" - git add config.json + git add config/config.json git commit -m "Update config.json" git remote set-url origin "https://${{ secrets.DCA_CONFIG_PAT }}@github.com/adamjtaylor/data_curator_config.git" git push --set-upstream origin update-csv-${{ github.run_id }}-${{ github.run_attempt }} From 0b8dfcf34f4c959ce05b820bf2a8963bed0986f9 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Fri, 30 Jun 2023 20:09:09 +0100 Subject: [PATCH 46/64] fix --- .github/workflows/ci-update-mtdca.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 92f6b8b4..9213db49 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -94,7 +94,7 @@ jobs: cp ../dcc_config.csv dcc_config.csv git add dcc_config.csv git commit -m "Update CSV with release tag" - git add config/config.json + git add config.json git commit -m "Update config.json" git remote set-url origin "https://${{ secrets.DCA_CONFIG_PAT }}@github.com/adamjtaylor/data_curator_config.git" git push --set-upstream origin update-csv-${{ github.run_id }}-${{ github.run_attempt }} From f395a2d5ac9ccffedc90c2dddda14d634039f19b Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Sat, 1 Jul 2023 09:41:29 +0100 Subject: [PATCH 47/64] Fix config paths --- .github/workflows/ci-update-mtdca.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 9213db49..81af2ce5 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -14,6 +14,7 @@ jobs: steps: - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 with: python-version: '3.9' @@ -79,23 +80,30 @@ jobs: echo "Using github.sha: ${{ github.sha }}" sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/[^/]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/${{ github.sha }}/HTAN.model.jsonld|" dcc_config.csv fi + - name: Commit and push changes to target repository run: | # Set up the GitHub token for authentication git config --global credential.helper store git config --global user.email "adam.taylor@sagebase.org" git config --global user.name "Adam Taylor" - # Replace `` with the username or organization name of the target repository owner - # Replace `` with the name of the target repository - # Replace `update-csv` with the name of the branch you want to push the changes to + + # Clone the config repo and make a branch git clone https://github.com/adamjtaylor/data_curator_config.git cd data_curator_config git checkout -b update-csv-${{ github.run_id }}-${{ github.run_attempt }} + + # Add the dcc_config.csv cp ../dcc_config.csv dcc_config.csv git add dcc_config.csv git commit -m "Update CSV with release tag" - git add config.json + + # Add the dca-template-config.json + mv ../config.json HTAN/dca-template-config.json + git add HTAN/dca-template-config.json git commit -m "Update config.json" + + # Push to the repository git remote set-url origin "https://${{ secrets.DCA_CONFIG_PAT }}@github.com/adamjtaylor/data_curator_config.git" git push --set-upstream origin update-csv-${{ github.run_id }}-${{ github.run_attempt }} From eeed54d0a1cce3f1e2ea66c613ba75310e224749 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Sat, 1 Jul 2023 09:59:13 +0100 Subject: [PATCH 48/64] Split into 3 jobs --- .github/workflows/ci-update-mtdca.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 81af2ce5..b8cfaceb 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -1,14 +1,11 @@ -name: Update CSV on Release +name: Update DCA config on release on: - pull_request: workflow_dispatch: release: - types: [prereleased] jobs: - make-config: runs-on: ubuntu-latest @@ -46,7 +43,6 @@ jobs: update-csv: runs-on: ubuntu-latest - needs: make-config steps: - name: Checkout repository @@ -81,6 +77,21 @@ jobs: sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/[^/]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/${{ github.sha }}/HTAN.model.jsonld|" dcc_config.csv fi + open-pr: + runs-on: ubuntu-latest + needs: + - make-config + - update-csv + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Fetch config.json artifact + uses: actions/download-artifact@master + with: + name: config + - name: Commit and push changes to target repository run: | # Set up the GitHub token for authentication From 7e9ea1910f51a872ee88f21feb9505b6eb2070cc Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Sat, 1 Jul 2023 10:02:18 +0100 Subject: [PATCH 49/64] Add release type for testing --- .github/workflows/ci-update-mtdca.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index b8cfaceb..7c2c13b9 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -1,8 +1,9 @@ name: Update DCA config on release on: - workflow_dispatch: release: + types: [prereleased] + workflow_dispatch: jobs: From 7d4bbf38f834a860bba5f91b70a5d75eb8a6d11c Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Sat, 1 Jul 2023 10:05:00 +0100 Subject: [PATCH 50/64] Remove artifact fetch when not required --- .github/workflows/ci-update-mtdca.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 7c2c13b9..e4d44b91 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -49,11 +49,6 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - - name: Fetch config.json artifact - uses: actions/download-artifact@master - with: - name: config - - name: Fetch CSV file from target repository run: | # Replace `` with the username or organization name of the target repository owner From fedf9e532dbdfebf22a76605ecf8e79ddbd25a8b Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Sat, 1 Jul 2023 10:11:03 +0100 Subject: [PATCH 51/64] Pass artifacts correctly --- .github/workflows/ci-update-mtdca.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index e4d44b91..c452568c 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -39,7 +39,7 @@ jobs: - name: Store config.json artifact uses: actions/upload-artifact@master with: - name: config + name: config_json path: config.json update-csv: @@ -73,6 +73,12 @@ jobs: sed -i "s|https://raw.githubusercontent.com/ncihtan/data-models/[^/]\+/HTAN.model.jsonld|https://raw.githubusercontent.com/ncihtan/data-models/${{ github.sha }}/HTAN.model.jsonld|" dcc_config.csv fi + - name: Store dcc_config.csv artifact + uses: actions/upload-artifact@master + with: + name: dcc_config_csv + path: dcc_config.csv + open-pr: runs-on: ubuntu-latest needs: @@ -86,7 +92,12 @@ jobs: - name: Fetch config.json artifact uses: actions/download-artifact@master with: - name: config + name: config_json + + - name: Fetch dcc_config.csv artifact + uses: actions/download-artifact@master + with: + name: dcc_config_csv - name: Commit and push changes to target repository run: | From 9789baae3d0028fb57a66cecd2137e4f1b655bf8 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Sat, 1 Jul 2023 10:52:31 +0100 Subject: [PATCH 52/64] Sort config by type and name --- .github/workflows/config_schema.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/config_schema.py b/.github/workflows/config_schema.py index 47960447..9067f835 100644 --- a/.github/workflows/config_schema.py +++ b/.github/workflows/config_schema.py @@ -46,6 +46,9 @@ def generate_schema_config(schema_path): sg = SchemaGenerator(path_to_json_ld=schema_path) component_digraph = sg.se.get_digraph_by_edge_type('requiresComponent') components = component_digraph.nodes() + components_to_remove = ['Patient', 'File', 'Publication'] + components = sorted(list(set(components) - set(components_to_remove))) + print(components) # get display names for required data types mm_graph = sg.se.get_nx_schema() display_names = sg.get_nodes_display_names(components, mm_graph) @@ -61,6 +64,18 @@ def generate_schema_config(schema_path): }) return schemas +def sort_manifest_schemas(s): + + ms = s['manifest_schemas'] + def key_func(schema): + return (schema['type'], schema['display_name']) + + sorted_schemas = sorted(ms, key=key_func) + + s['manifest_schemas'] = sorted_schemas + return s + + def main(): args = get_args() @@ -85,6 +100,7 @@ def main(): 'service_version': '1', #service_version, 'schema_version': '1' #schema_version } + config = sort_manifest_schemas(config) output_path = os.path.join(args.out_dir, 'config.json') with open(output_path, 'w') as o: json.dump(config, o, indent=2, separators=(',', ': ')) From 51c0113b86da919e08d2a366824322d3807b6d31 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Tue, 15 Aug 2023 19:35:04 +0100 Subject: [PATCH 53/64] Update ci-update-mtdca.yml --- .github/workflows/ci-update-mtdca.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index c452568c..c409e09b 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -122,7 +122,7 @@ jobs: git commit -m "Update config.json" # Push to the repository - git remote set-url origin "https://${{ secrets.DCA_CONFIG_PAT }}@github.com/adamjtaylor/data_curator_config.git" + git remote set-url origin "https://${{ secrets.DCA_CONFIG_PAT }}@github.com/ncihtan/data_curator_config.git" git push --set-upstream origin update-csv-${{ github.run_id }}-${{ github.run_attempt }} - name: Create pull request From ec3277edf9cb1cd97382c9652f695bbaf7f9f62c Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Wed, 16 Aug 2023 13:54:23 +0100 Subject: [PATCH 54/64] Update actions --- .github/workflows/ci-mtdca-config-pr | 26 ++++++++++++++++++++++++++ .github/workflows/ci-update-mtdca.yml | 20 ++------------------ .github/workflows/config_schema.py | 2 +- 3 files changed, 29 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/ci-mtdca-config-pr diff --git a/.github/workflows/ci-mtdca-config-pr b/.github/workflows/ci-mtdca-config-pr new file mode 100644 index 00000000..bca43be5 --- /dev/null +++ b/.github/workflows/ci-mtdca-config-pr @@ -0,0 +1,26 @@ +name: Push config to mtDCA + +on: + merge: + workflow-dispatch: + +jobs: + pull-request: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Create pull request + uses: paygoc6/action-pull-request-another-repo@v1.0.1 + env: + API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} + with: + source_folder: 'source-folder' + destination_repo: 'ncihtan/data_curator_config' + destination_folder: 'HTAN' + destination_base_branch: 'main' + destination_head_branch: 'update-htan-config' + user_email: 'adam.taylor@sagebase.org' + user_name: 'adamjtaylor' + pull_request_reviewers: 'adamjtaylor' \ No newline at end of file diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index c409e09b..de0cb7ae 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -26,22 +26,6 @@ jobs: poetry build pip3 install dist/schematicpy-*-py3-none-any.whl - - name: Make config file from data model - shell: bash - run: | - python .github/workflows/config_schema.py \ - -c config.yml \ - -s HTAN.model.jsonld \ - -o '.' \ - --service_repo 'Sage-Bionetworks/schematic' \ - --overwrite - - - name: Store config.json artifact - uses: actions/upload-artifact@master - with: - name: config_json - path: config.json - update-csv: runs-on: ubuntu-latest @@ -117,9 +101,9 @@ jobs: git commit -m "Update CSV with release tag" # Add the dca-template-config.json - mv ../config.json HTAN/dca-template-config.json + mv ../dca-template-config.json HTAN/dca-template-config.json git add HTAN/dca-template-config.json - git commit -m "Update config.json" + git commit -m "Update dca-template-config.json" # Push to the repository git remote set-url origin "https://${{ secrets.DCA_CONFIG_PAT }}@github.com/ncihtan/data_curator_config.git" diff --git a/.github/workflows/config_schema.py b/.github/workflows/config_schema.py index 9067f835..65f4a3af 100644 --- a/.github/workflows/config_schema.py +++ b/.github/workflows/config_schema.py @@ -101,7 +101,7 @@ def main(): 'schema_version': '1' #schema_version } config = sort_manifest_schemas(config) - output_path = os.path.join(args.out_dir, 'config.json') + output_path = os.path.join(args.out_dir, 'dca-template-config.json') with open(output_path, 'w') as o: json.dump(config, o, indent=2, separators=(',', ': ')) From 6b0b36bd0648b83e218479f7385af5d1d1e068f9 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Wed, 16 Aug 2023 13:56:34 +0100 Subject: [PATCH 55/64] Update pat --- .github/workflows/ci-mtdca-config-pr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-mtdca-config-pr b/.github/workflows/ci-mtdca-config-pr index bca43be5..5204561e 100644 --- a/.github/workflows/ci-mtdca-config-pr +++ b/.github/workflows/ci-mtdca-config-pr @@ -14,7 +14,7 @@ jobs: - name: Create pull request uses: paygoc6/action-pull-request-another-repo@v1.0.1 env: - API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} + API_TOKEN_GITHUB: ${{ secrets.ADD_TO_PROJECT_PAT }} with: source_folder: 'source-folder' destination_repo: 'ncihtan/data_curator_config' From 2e995ac1f9504e3aee08db53393b99c682b2447e Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Wed, 16 Aug 2023 14:12:36 +0100 Subject: [PATCH 56/64] Make the config file in the Lint Convert action --- .../workflows/ci-lint-validate-convert.yml | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/.github/workflows/ci-lint-validate-convert.yml b/.github/workflows/ci-lint-validate-convert.yml index 718fd104..79bdd927 100644 --- a/.github/workflows/ci-lint-validate-convert.yml +++ b/.github/workflows/ci-lint-validate-convert.yml @@ -126,3 +126,51 @@ jobs: - uses: r-lib/actions/pr-push@v2 with: repo-token: ${{ secrets.GITHUB_TOKEN }} + + config: + name: Make config file from data model + needs: + - convert + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.9' + + - name: Install Schematic + shell: bash + run: | + pip3 install poetry + git clone --single-branch --branch main https://github.com/Sage-Bionetworks/schematic.git + cd schematic + poetry build + pip3 install dist/schematicpy-*-py3-none-any.whl + + - name: Make config file from data model + shell: bash + run: | + python .github/workflows/config_schema.py \ + -c config.yml \ + -s HTAN.model.jsonld \ + -o '.' \ + --service_repo 'Sage-Bionetworks/schematic' \ + --overwrite + + - uses: r-lib/actions/pr-fetch@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Commit the changes + run: | + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + git add HTAN.model.jsonld + git commit -m "GitHub Action: Make config from data model" || echo "No changes to commit" + + - uses: r-lib/actions/pr-push@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 9a8e6740a5a6de2354e39e04df7ffeb760c77ddf Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Thu, 31 Aug 2023 09:42:45 +0100 Subject: [PATCH 57/64] Change mtdca config runon --- .github/workflows/ci-update-mtdca.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index de0cb7ae..e710abf8 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -1,8 +1,6 @@ name: Update DCA config on release on: - release: - types: [prereleased] workflow_dispatch: jobs: From c9d9f21b6334d07f51856d202523baa565c15f29 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Thu, 31 Aug 2023 09:44:06 +0100 Subject: [PATCH 58/64] Fix workflow dispatch --- .github/workflows/ci-update-mtdca.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index e710abf8..6c09c19a 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -1,7 +1,6 @@ name: Update DCA config on release -on: - workflow_dispatch: +on: workflow_dispatch jobs: From c4b83668097e795ecfe3e6b704070b72c855241c Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Thu, 31 Aug 2023 09:59:02 +0100 Subject: [PATCH 59/64] Run on publish --- .github/workflows/ci-update-mtdca.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 6c09c19a..1370f7fe 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -1,6 +1,9 @@ name: Update DCA config on release -on: workflow_dispatch +on: + release: + types: [published] + workflow_dispatch: jobs: From 14fbb2d555472e307bad0451b29afafd12db5897 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Thu, 31 Aug 2023 10:07:26 +0100 Subject: [PATCH 60/64] Add make config step --- .github/workflows/ci-update-mtdca.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 1370f7fe..b17e8dcf 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -25,6 +25,11 @@ jobs: cd schematic poetry build pip3 install dist/schematicpy-*-py3-none-any.whl + + - name: Make config + shell: bash + run: | + python .github/workflows/config_schema.py -c config.yml -s HTAN.model.jsonld -o . --overwrite update-csv: runs-on: ubuntu-latest From 3865f55d01add9e774d8cade077d0feed7f2c0ef Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Thu, 31 Aug 2023 10:25:27 +0100 Subject: [PATCH 61/64] Target Sage-Bionetworks/data_curator_config --- .github/workflows/ci-update-mtdca.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index b17e8dcf..3d578d23 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -46,7 +46,7 @@ jobs: curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ -H "Accept: application/vnd.github.v3.raw" \ -o dcc_config.csv \ - -L "https://raw.githubusercontent.com/adamjtaylor/data_curator_config/main/dcc_config.csv" + -L "https://raw.githubusercontent.com/Sage-Bionetworks/data_curator_config/main/dcc_config.csv" - name: Modify CSV file run: | @@ -96,7 +96,7 @@ jobs: git config --global user.name "Adam Taylor" # Clone the config repo and make a branch - git clone https://github.com/adamjtaylor/data_curator_config.git + git clone https://github.com/Sage-Bionetworks/data_curator_config.git cd data_curator_config git checkout -b update-csv-${{ github.run_id }}-${{ github.run_attempt }} @@ -111,7 +111,7 @@ jobs: git commit -m "Update dca-template-config.json" # Push to the repository - git remote set-url origin "https://${{ secrets.DCA_CONFIG_PAT }}@github.com/ncihtan/data_curator_config.git" + git remote set-url origin "https://${{ secrets.DCA_CONFIG_PAT }}@github.com/Sage-Bionetworks/data_curator_config.git" git push --set-upstream origin update-csv-${{ github.run_id }}-${{ github.run_attempt }} - name: Create pull request @@ -119,7 +119,7 @@ jobs: curl -X POST \ -H "Authorization: Bearer ${{ secrets.DCA_CONFIG_PAT }}" \ -H "Accept: application/vnd.github.v3+json" \ - "https://api.github.com/repos/adamjtaylor/data_curator_config/pulls" \ + "https://api.github.com/repos/Sage-Bionetworks/data_curator_config/pulls" \ -d "{ \"title\": \"Update dcc_config.csv with new data model\", \"head\": \"update-csv-${{ github.run_id }}-${{ github.run_attempt }}\", From ba4f0879a928c5fcfc35b1701c6aac0edc0c148e Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Thu, 31 Aug 2023 10:28:44 +0100 Subject: [PATCH 62/64] Fix artefact names --- .github/workflows/ci-update-mtdca.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index 3d578d23..b4f133fc 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -31,6 +31,12 @@ jobs: run: | python .github/workflows/config_schema.py -c config.yml -s HTAN.model.jsonld -o . --overwrite + - name: Store dca-template-config.json artifact + uses: actions/upload-artifact@master + with: + name: dca_template_config_json + path: dca-template-config.json + update-csv: runs-on: ubuntu-latest @@ -78,10 +84,10 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - - name: Fetch config.json artifact + - name: Fetch dca_template_config_json artifact uses: actions/download-artifact@master with: - name: config_json + name: dca_template_config_json - name: Fetch dcc_config.csv artifact uses: actions/download-artifact@master From caebc65019fa1fa8fb941ce5929538bcdfe9ebe1 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Thu, 31 Aug 2023 10:41:20 +0100 Subject: [PATCH 63/64] Make branch in ncihtan --- .github/workflows/ci-update-mtdca.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-update-mtdca.yml b/.github/workflows/ci-update-mtdca.yml index b4f133fc..56861df1 100644 --- a/.github/workflows/ci-update-mtdca.yml +++ b/.github/workflows/ci-update-mtdca.yml @@ -117,7 +117,7 @@ jobs: git commit -m "Update dca-template-config.json" # Push to the repository - git remote set-url origin "https://${{ secrets.DCA_CONFIG_PAT }}@github.com/Sage-Bionetworks/data_curator_config.git" + git remote set-url origin "https://${{ secrets.DCA_CONFIG_PAT }}@github.com/ncihtan/data_curator_config.git" git push --set-upstream origin update-csv-${{ github.run_id }}-${{ github.run_attempt }} - name: Create pull request @@ -128,7 +128,7 @@ jobs: "https://api.github.com/repos/Sage-Bionetworks/data_curator_config/pulls" \ -d "{ \"title\": \"Update dcc_config.csv with new data model\", - \"head\": \"update-csv-${{ github.run_id }}-${{ github.run_attempt }}\", + \"head\": \"ncihtan:update-csv-${{ github.run_id }}-${{ github.run_attempt }}\", \"base\": \"main\", \"body\": \"This pull request updates the CSV file with the release tag or commit sha\", \"draft\": \"true\" From 4d253cd70e7ec2b044ca0df706870ccb0895a8e8 Mon Sep 17 00:00:00 2001 From: Adam Taylor Date: Wed, 27 Sep 2023 12:53:14 +0100 Subject: [PATCH 64/64] Update schema script --- .github/workflows/config_schema.py | 77 +++++++++--------------------- 1 file changed, 23 insertions(+), 54 deletions(-) diff --git a/.github/workflows/config_schema.py b/.github/workflows/config_schema.py index 65f4a3af..62d6c53c 100644 --- a/.github/workflows/config_schema.py +++ b/.github/workflows/config_schema.py @@ -9,26 +9,15 @@ def get_args(): """Set up command-line interface and get arguments.""" parser = argparse.ArgumentParser() - parser.add_argument('-c', '--config_path', metavar="", - required=True, help='path to schematic config ymal file') - parser.add_argument('-s','--schema_path', metavar = "", - required=True, help='path to schema jsonld file') - parser.add_argument('-sr', '--service_repo', metavar="", - help='repo path to service') - parser.add_argument('-o', '--out_dir', default='www', metavar="", - help='directory to save result') - parser.add_argument('--overwrite', action='store_true', default=False, - help='whether to overwrite the existing config.json') + parser.add_argument('-c', '--config_path', required=True, + help='Path to Schematic config YAML file') + parser.add_argument('-s', '--schema_path', required=True, + help='Path to schema JSON-LD file') + parser.add_argument('-o', '--out_dir', default='.', + help='Directory to save result') return parser.parse_args() -def _is_valid(value, type): - if type not in ["repo", "location"]: - raise ValueError('type must be "repo" or "location"') - pattern = "^([-_.A-z0-9]+\\/){1,2}[-_.A-z0-9]+$" if type == "repo" else "^[-_.A-z0-9]+\\/.*.jsonld$" - return bool(re.match(pattern, value)) - - def _parse_schema(config_path): """Parse schematic_config.yml file""" with open(config_path, "r") as stream: @@ -42,19 +31,14 @@ def _parse_schema(config_path): def generate_schema_config(schema_path): """Generate schema config with corresponding display name""" schemas = [] - # get all required data types from data model jsonld sg = SchemaGenerator(path_to_json_ld=schema_path) component_digraph = sg.se.get_digraph_by_edge_type('requiresComponent') components = component_digraph.nodes() components_to_remove = ['Patient', 'File', 'Publication'] - components = sorted(list(set(components) - set(components_to_remove))) - print(components) - # get display names for required data types + components = sorted(list(set(components) - set(components_to_remove))) mm_graph = sg.se.get_nx_schema() display_names = sg.get_nodes_display_names(components, mm_graph) - # save display_name, schema_name, assay type to list for index, component in enumerate(components): - # get component's dependencies deps = sg.get_node_dependencies(component) schema_type = 'file' if 'Filename' in deps else 'record' schemas.append({ @@ -64,47 +48,32 @@ def generate_schema_config(schema_path): }) return schemas -def sort_manifest_schemas(s): +def sort_manifest_schemas(s): + """Sorts the schema entries in ascending order""" ms = s['manifest_schemas'] - def key_func(schema): - return (schema['type'], schema['display_name']) - - sorted_schemas = sorted(ms, key=key_func) - + sorted_schemas = sorted(ms, key=lambda schema: (schema['type'], schema['display_name'])) s['manifest_schemas'] = sorted_schemas return s - def main(): args = get_args() - # retrieve schema info from config file config = _parse_schema(args.config_path) - - # get the location of the schema - #if config.get("location") and _is_valid(config.get("location"), "location"): schema_path = args.schema_path - #else: - # raise ValueError(f'No valid "location" value found in "{args.config_path}" \u274C') - - if args.overwrite: - # get versions for both service and schema - #service_version = _get_version(args.service_repo) - #schema_version = config.get("version") or _get_version(config["repo"]) - # generate schema configuration based on *.model.jsonld - schemas_config = generate_schema_config(schema_path) - # write out the config.json including versions - config = { - 'manifest_schemas': schemas_config, - 'service_version': '1', #service_version, - 'schema_version': '1' #schema_version - } - config = sort_manifest_schemas(config) - output_path = os.path.join(args.out_dir, 'dca-template-config.json') - with open(output_path, 'w') as o: - json.dump(config, o, indent=2, separators=(',', ': ')) + schemas_config = generate_schema_config(schema_path) + + config = { + 'manifest_schemas': schemas_config, + 'service_version': '1.0', + 'schema_version': '1.0' + } + config = sort_manifest_schemas(config) + + output_path = os.path.join(args.out_dir, 'dca-template-config.json') + with open(output_path, 'w') as o: + json.dump(config, o, indent=2, separators=(',', ': ')) if __name__ == '__main__': - main() + main() \ No newline at end of file