From faa9a0684e7c6122b328b9cb727f9eba8d48a4f7 Mon Sep 17 00:00:00 2001 From: Yibei Chen Date: Mon, 17 Jun 2024 13:16:42 +0000 Subject: [PATCH 1/7] rename branch to main, add release yml --- .github/workflows/pythonpackage.yml | 6 ++-- .github/workflows/pythonpublish.yml | 4 +-- .github/workflows/release.yml | 43 +++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 72f6446..78ce594 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -5,9 +5,9 @@ name: Python package on: push: - branches: [ master ] + branches: [ main ] pull_request: - branches: [ master ] + branches: [ main ] jobs: build: @@ -16,7 +16,7 @@ jobs: strategy: matrix: os: [macos-latest, ubuntu-latest] - python-version: [3.8, 3.9, "3.10", "3.11", "3.12"] + python-version: ["3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml index b2b39f5..d3635eb 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/pythonpublish.yml @@ -13,9 +13,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v4 with: python-version: '3.x' - name: Install dependencies diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..cbd9902 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,43 @@ +name: Auto-release on PR merge + +on: + # ATM, this is the closest trigger to a PR merging + push: + branches: + - main + +env: + AUTO_VERSION: v11.0.5 + +jobs: + auto-release: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')" + steps: + - uses: actions/checkout@v3 + + - name: Prepare repository + # Fetch full git history and tags + run: git fetch --unshallow --tags + + - name: Unset header + # checkout@v2 adds a header that makes branch protection report errors + # because the Github action bot is not a collaborator on the repo + run: git config --local --unset http.https://github.com/.extraheader + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + + - name: Download auto + run: | + auto_download_url="$(curl -fsSL https://api.github.com/repos/intuit/auto/releases/tags/$AUTO_VERSION | jq -r '.assets[] | select(.name == "auto-linux.gz") | .browser_download_url')" + wget -O- "$auto_download_url" | gunzip > ~/auto + chmod a+x ~/auto + + - name: Create release + run: | + ~/auto shipit -vv + env: + GH_TOKEN: ${{ secrets.AUTO_ORG_TOKEN }} From 5e88c278e3d9928807ba5e384c2eadfa692dc9a9 Mon Sep 17 00:00:00 2001 From: Yibei Chen Date: Mon, 17 Jun 2024 13:31:10 +0000 Subject: [PATCH 2/7] set ga to fetch and update release version for context url --- .github/workflows/update_context.yml | 41 ++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/update_context.yml diff --git a/.github/workflows/update_context.yml b/.github/workflows/update_context.yml new file mode 100644 index 0000000..4eeff66 --- /dev/null +++ b/.github/workflows/update_context.yml @@ -0,0 +1,41 @@ +name: Update CONTEXTFILE_URL + +on: + schedule: + - cron: '0 0 * * 0' # Runs weekly at midnight on Sunday + workflow_dispatch: + +jobs: + update-url: + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Get latest release tag from reproschema + id: get_latest_release + run: | + latest_release=$(curl -s https://api.github.com/repos/ReproNim/reproschema/releases/latest | jq -r .tag_name) + echo "Latest release: $latest_release" + echo "::set-output name=latest_release::$latest_release" + + - name: Update CONTEXTFILE_URL in the repository + run: | + latest_release=${{ steps.get_latest_release.outputs.latest_release }} + sed -i "s|CONTEXTFILE_URL = \"https://raw.githubusercontent.com/ReproNim/reproschema/.*/contexts/reproschema\"|CONTEXTFILE_URL = \"https://raw.githubusercontent.com/ReproNim/reproschema/$latest_release/contexts/reproschema\"|" reproschema-py/reproschema/utils.py + + - name: Commit and push changes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git add reproschema-py/reproschema/utils.py + git commit -m "Update CONTEXTFILE_URL to latest release $latest_release" + git push \ No newline at end of file From ea3105d1d02a839061a7aace40af333060373c7e Mon Sep 17 00:00:00 2001 From: Yibei Chen Date: Mon, 17 Jun 2024 13:34:53 +0000 Subject: [PATCH 3/7] low GA checking frequency --- .github/workflows/update_context.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_context.yml b/.github/workflows/update_context.yml index 4eeff66..e313feb 100644 --- a/.github/workflows/update_context.yml +++ b/.github/workflows/update_context.yml @@ -2,7 +2,7 @@ name: Update CONTEXTFILE_URL on: schedule: - - cron: '0 0 * * 0' # Runs weekly at midnight on Sunday + - cron: '0 0 1 * *' # Runs weekly at midnight on Sunday workflow_dispatch: jobs: From 50c03a6cd3580e3e9bb43652e1b3f05eb72879d6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 13:35:39 +0000 Subject: [PATCH 4/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .github/workflows/update_context.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_context.yml b/.github/workflows/update_context.yml index e313feb..fe3dc18 100644 --- a/.github/workflows/update_context.yml +++ b/.github/workflows/update_context.yml @@ -38,4 +38,4 @@ jobs: git config --global user.email "github-actions[bot]@users.noreply.github.com" git add reproschema-py/reproschema/utils.py git commit -m "Update CONTEXTFILE_URL to latest release $latest_release" - git push \ No newline at end of file + git push From 98907db82d003c92fc5ff2f185d845446900f47e Mon Sep 17 00:00:00 2001 From: Yibei Chen Date: Mon, 17 Jun 2024 14:00:39 +0000 Subject: [PATCH 5/7] comment out breakpoint() --- reproschema/tests/test_rs2redcap_redcap2rs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reproschema/tests/test_rs2redcap_redcap2rs.py b/reproschema/tests/test_rs2redcap_redcap2rs.py index 15bf632..e56bd26 100644 --- a/reproschema/tests/test_rs2redcap_redcap2rs.py +++ b/reproschema/tests/test_rs2redcap_redcap2rs.py @@ -356,7 +356,7 @@ def test_rs2redcap_redcap2rs(tmpdir): ) protocol_schema_final = "output_nimh/nimh_minimal/nimh_minimal/nimh_minimal_schema" - breakpoint() + # breakpoint() http_kwargs = {} stop, port = start_server() http_kwargs["port"] = port From ade7613d78d2beae1ace07be0a92159a6a35fad1 Mon Sep 17 00:00:00 2001 From: Yibei Chen Date: Fri, 21 Jun 2024 14:52:37 +0000 Subject: [PATCH 6/7] rename files, refactor code --- .../{pythonpackage.yml => package.yml} | 0 .../{pythonpublish.yml => publish.yml} | 0 .github/workflows/update_context.yml | 41 ------------------- reproschema/jsonldutils.py | 10 +---- reproschema/reproschema2redcap.py | 7 +--- 5 files changed, 3 insertions(+), 55 deletions(-) rename .github/workflows/{pythonpackage.yml => package.yml} (100%) rename .github/workflows/{pythonpublish.yml => publish.yml} (100%) delete mode 100644 .github/workflows/update_context.yml diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/package.yml similarity index 100% rename from .github/workflows/pythonpackage.yml rename to .github/workflows/package.yml diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/publish.yml similarity index 100% rename from .github/workflows/pythonpublish.yml rename to .github/workflows/publish.yml diff --git a/.github/workflows/update_context.yml b/.github/workflows/update_context.yml deleted file mode 100644 index fe3dc18..0000000 --- a/.github/workflows/update_context.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Update CONTEXTFILE_URL - -on: - schedule: - - cron: '0 0 1 * *' # Runs weekly at midnight on Sunday - workflow_dispatch: - -jobs: - update-url: - runs-on: ubuntu-latest - - steps: - - name: Check out repository - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - - name: Get latest release tag from reproschema - id: get_latest_release - run: | - latest_release=$(curl -s https://api.github.com/repos/ReproNim/reproschema/releases/latest | jq -r .tag_name) - echo "Latest release: $latest_release" - echo "::set-output name=latest_release::$latest_release" - - - name: Update CONTEXTFILE_URL in the repository - run: | - latest_release=${{ steps.get_latest_release.outputs.latest_release }} - sed -i "s|CONTEXTFILE_URL = \"https://raw.githubusercontent.com/ReproNim/reproschema/.*/contexts/reproschema\"|CONTEXTFILE_URL = \"https://raw.githubusercontent.com/ReproNim/reproschema/$latest_release/contexts/reproschema\"|" reproschema-py/reproschema/utils.py - - - name: Commit and push changes - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git add reproschema-py/reproschema/utils.py - git commit -m "Update CONTEXTFILE_URL to latest release $latest_release" - git push diff --git a/reproschema/jsonldutils.py b/reproschema/jsonldutils.py index f3cc624..9ac65b3 100644 --- a/reproschema/jsonldutils.py +++ b/reproschema/jsonldutils.py @@ -6,15 +6,7 @@ from pyld import jsonld from .context_url import CONTEXTFILE_URL -from .models import ( - Activity, - Item, - Protocol, - Response, - ResponseActivity, - ResponseOption, - identify_model_class, -) +from .models import identify_model_class from .utils import fixing_old_schema, lgr, start_server, stop_server diff --git a/reproschema/reproschema2redcap.py b/reproschema/reproschema2redcap.py index fceae42..1b20843 100644 --- a/reproschema/reproschema2redcap.py +++ b/reproschema/reproschema2redcap.py @@ -4,17 +4,14 @@ import requests from .context_url import CONTEXTFILE_URL -from .jsonldutils import _is_file, _is_url, load_file +from .jsonldutils import _is_url, load_file from .models import ( Activity, Item, Protocol, - Response, - ResponseActivity, ResponseOption, - write_obj_jsonld, ) -from .utils import fixing_old_schema, start_server, stop_server +from .utils import start_server, stop_server def fetch_choices_from_url(url): From 2049e3a73b21d0ab19dedc6a45a4094a3689495b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 21 Jun 2024 14:52:45 +0000 Subject: [PATCH 7/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- reproschema/reproschema2redcap.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/reproschema/reproschema2redcap.py b/reproschema/reproschema2redcap.py index 1b20843..5650e82 100644 --- a/reproschema/reproschema2redcap.py +++ b/reproschema/reproschema2redcap.py @@ -5,12 +5,7 @@ from .context_url import CONTEXTFILE_URL from .jsonldutils import _is_url, load_file -from .models import ( - Activity, - Item, - Protocol, - ResponseOption, -) +from .models import Activity, Item, Protocol, ResponseOption from .utils import start_server, stop_server