diff --git a/.github/workflows/schemacode_ci.yml b/.github/workflows/schemacode_ci.yml index e9015656ca..3d06c891a3 100644 --- a/.github/workflows/schemacode_ci.yml +++ b/.github/workflows/schemacode_ci.yml @@ -4,9 +4,12 @@ on: push: branches: - "master" + - "autodata" paths: - "tools/schemacode/**" - "src/schema/**" + tags: + - "schema-*" pull_request: branches: - "*" @@ -54,6 +57,35 @@ jobs: shell: bash {0} run: python -c "import sys; print(sys.version)" + - name: "DO WITH tags!!!" + shell: bash {0} + run: | + echo ${{ github.GITHUB_REF }} + echo ${{ github.CI }} + echo ${{ github.workspace.GITHUB_REF }} + echo ${{ github.workspace.CI }} + echo ${{ env.GITHUB_REF }} + echo ${{ env.CI }} + echo $GITHUB_REF + echo $CI + echo "$GITHUB_REF" + echo "$CI" + echo ${GITHUB_REF} + echo ${CI} + pwd + ls -lah + cat .git/COMMIT_EDITMSG + tree .git + which git + git ls-remote --tags + git describe --tags + git describe --tags + git describe --tags + MY_TAG="$(git describe --tags)" + if [ "${MY_TAG:0:7}" = "schema-" ]; then + echo "BIDSSCHEMATOOLS_RELEASE=1" >> $GITHUB_ENV + fi + - name: "Install the schemacode package" shell: bash {0} run: | @@ -65,6 +97,26 @@ jobs: run: | python -m pytest --pyargs bidsschematools -m "not validate_schema" --cov-append --cov-report=xml --cov=bidsschematools + - name: "Test upload" + shell: bash {0} + id: testpypi_upload + run: | + if [ -z "$BIDSSCHEMATOOLS_RELEASE" ]; then + echo "BIDSSCHEMATOOLS_RELEASE is set to '$BIDSSCHEMATOOLS_RELEASE'" + ls /tmp/bidsschematools* -lah + python -m build + twine upload -u __token__ -p ${{secrets.BIDS_TOKEN_TEST}} --repository testpypi dist/* + fi + + - name: "Real upload" + shell: bash {0} + if: ${{ success(testpypi_upload) }} + run: | + if [ -z "$BIDSSCHEMATOOLS_RELEASE" ]; then + echo "BIDSSCHEMATOOLS_RELEASE is set to '$BIDSSCHEMATOOLS_RELEASE'" + twine upload -u __token__ -p ${{secrets.BIDS_TOKEN_TEST}} --repository dist/* + fi + - name: Upload artifacts uses: actions/upload-artifact@v2 with: diff --git a/scripts/test_tag b/scripts/test_tag new file mode 100755 index 0000000000..1a7a0227d0 --- /dev/null +++ b/scripts/test_tag @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +VERSION_FILE="src/schema/SCHEMA_VERSION" + +pushd .. + export MY_BIDS_DATE="$(date +%s)" + REAL_VERSION=$(cat "${VERSION_FILE}") + DUMMY_VERSION="0.0.${MY_BIDS_DATE}-dev" + echo "${DUMMY_VERSION}" > "${VERSION_FILE}" + git commit -a -m "debug" + git tag -a "schema-$DUMMY_VERSION" -m "debug" + git push origin + git push origin "schema-$DUMMY_VERSION" + echo "${REAL_VERSION}" > "${VERSION_FILE}" +popd +unset MY_BIDS_DATE + diff --git a/src/schema/SCHEMA_VERSION b/src/schema/SCHEMA_VERSION index 25a5afd80b..2b304e0d74 100644 --- a/src/schema/SCHEMA_VERSION +++ b/src/schema/SCHEMA_VERSION @@ -1 +1 @@ -0.4.0-dev +0.0.1661358808-dev diff --git a/tools/schemacode/bidsschematools/tests/conftest.py b/tools/schemacode/bidsschematools/tests/conftest.py index 08cac5e6a6..afd7e5f8c8 100644 --- a/tools/schemacode/bidsschematools/tests/conftest.py +++ b/tools/schemacode/bidsschematools/tests/conftest.py @@ -35,19 +35,20 @@ def get_gitrepo_fixture(url, whitelist): @pytest.fixture(scope="session") def fixture(): archive_name = url.rsplit("/", 1)[-1] - testdata_archive = os.path.join(os.getcwd(), "testdata", archive_name) - if os.path.isdir(testdata_archive): + testdata_dir = os.path.join(os.path.dirname(__file__),"data","bundled",archive_name) + testdata_dir = os.path.abspath(testdata_dir) + if os.path.isdir(testdata_dir): lgr.info( "Found static testdata archive under `%s`. " "Not downloading latest data from version control.", - testdata_archive, + testdata_dir, ) - yield testdata_archive + yield testdata_dir else: lgr.info( "No static testdata available under `%s`. " "Attempting to fetch live data from version control.", - testdata_archive, + testdata_dir, ) with tempfile.TemporaryDirectory() as path: assert os.path.exists(path) diff --git a/tools/schemacode/bidsschematools/tests/test_make_testdata.py b/tools/schemacode/bidsschematools/tests/test_make_testdata.py index 11524f9b5a..22c4859a4e 100644 --- a/tools/schemacode/bidsschematools/tests/test_make_testdata.py +++ b/tools/schemacode/bidsschematools/tests/test_make_testdata.py @@ -1,5 +1,6 @@ import os import tarfile +import shutil import pytest @@ -30,9 +31,15 @@ def test_make_archive(bids_examples, bids_error_examples): * Archives will be generated under `/tmp/bidsschematools-testdata-SCHEMA_VERSION.tar.gz` """ - archive_name = f"bidsschematools-testdata-{__version__}" - archive_path = f"/tmp/{archive_name}.tar.gz" + target_dir = os.path.abspath(os.path.join(os.path.dirname(__file__),"data","bundled")) + os.makedirs(target_dir, exist_ok = True) + shutil.copytree(bids_examples, f"{target_dir}/bids-examples") + shutil.copytree(bids_error_examples, f"{target_dir}/bids-error-examples") - with tarfile.open(archive_path, "w:gz") as tar: - tar.add(bids_examples, arcname=f"{archive_name}/bids-examples") - tar.add(bids_error_examples, arcname=f"{archive_name}/bids-error-examples") + # Keeping this for now, it would be really nice to have a separate archive someday. + # archive_name = f"bidsschematools-testdata-{__version__}" + # archive_path = f"/tmp/{archive_name}.tar.gz" + + # with tarfile.open(archive_path, "w:gz") as tar: + # tar.add(bids_examples, arcname=f"{archive_name}/bids-examples") + # tar.add(bids_error_examples, arcname=f"{archive_name}/bids-error-examples") diff --git a/tools/schemacode/setup.cfg b/tools/schemacode/setup.cfg index 56da3eb0df..eb55393ddd 100644 --- a/tools/schemacode/setup.cfg +++ b/tools/schemacode/setup.cfg @@ -52,7 +52,7 @@ bidsschematools = data/schema/BIDS_VERSION data/schema/SCHEMA_VERSION data/schema/**/*.yaml - tests/data/* + tests/data/**/* [options.entry_points] console_scripts =