From e89c3b69052ff43b6fe8061371812a518f0f557e Mon Sep 17 00:00:00 2001 From: Yibei Chen Date: Fri, 21 Jun 2024 10:59:18 -0400 Subject: [PATCH] [ENH] release prep (#45) * rename branch to main, add release yml * set ga to fetch and update release version for context url * low GA checking frequency * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * comment out breakpoint() * rename files, refactor code * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .../{pythonpackage.yml => package.yml} | 2 +- .../{pythonpublish.yml => publish.yml} | 4 +- .github/workflows/release.yml | 43 +++++++++++++++++++ reproschema/jsonldutils.py | 10 +---- reproschema/reproschema2redcap.py | 14 ++---- 5 files changed, 50 insertions(+), 23 deletions(-) rename .github/workflows/{pythonpackage.yml => package.yml} (94%) rename .github/workflows/{pythonpublish.yml => publish.yml} (92%) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/package.yml similarity index 94% rename from .github/workflows/pythonpackage.yml rename to .github/workflows/package.yml index 6c5c301..78ce594 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/package.yml @@ -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/publish.yml similarity index 92% rename from .github/workflows/pythonpublish.yml rename to .github/workflows/publish.yml index 20a5e0d..94952ea 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/publish.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 }} 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..5650e82 100644 --- a/reproschema/reproschema2redcap.py +++ b/reproschema/reproschema2redcap.py @@ -4,17 +4,9 @@ import requests from .context_url import CONTEXTFILE_URL -from .jsonldutils import _is_file, _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 .jsonldutils import _is_url, load_file +from .models import Activity, Item, Protocol, ResponseOption +from .utils import start_server, stop_server def fetch_choices_from_url(url):