From a06cb4593ef1a11b3c9826f7ca5532a1bf83f67f Mon Sep 17 00:00:00 2001 From: akikuno Date: Wed, 22 May 2024 09:32:55 +0900 Subject: [PATCH] Add a test to check if the version in `test_version.sh` matches the version in `pyproject.toml` and `utils.config` --- .github/workflows/cli-tests.yml | 64 +++++++++++++++++++++++++++++++++ tests/test_version.sh | 9 +++++ 2 files changed, 73 insertions(+) create mode 100644 .github/workflows/cli-tests.yml create mode 100644 tests/test_version.sh diff --git a/.github/workflows/cli-tests.yml b/.github/workflows/cli-tests.yml new file mode 100644 index 0000000..d11cd31 --- /dev/null +++ b/.github/workflows/cli-tests.yml @@ -0,0 +1,64 @@ +name: cli-tests + +on: + push: + schedule: + - cron: "0 2 * * 1" # The task runs at 2 a.m. every Monday. + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + max-parallel: 2 + matrix: + os: [ubuntu-latest, macos-latest] + name: Bash on ${{ matrix.os }} + steps: + ########################################## + # Setup DAJIN2 + ########################################## + + - uses: actions/checkout@v4 + - uses: conda-incubator/setup-miniconda@v3 + with: + python-version: 3.10 + miniconda-version: "latest" + activate-environment: test-env + channels: bioconda, conda-forge, defaults, anaconda + + - name: Setup conda environment on ubuntu-latest🐧 + if: runner.os == 'Linux' + run: | + conda create -y -n env-dajin2 python=3.10 + + - name: Setup conda environment on macos-latest🍎 + if: runner.os == 'macOS' + run: | + # ========================================== + # Use Rosseta for macOS because the Bioconda channel does not yet support Apple Silicon + # ========================================== + CONDA_SUBDIR=osx-64 conda create -y -n env-dajin2 python=3.10 + conda activate env-dajin2 + conda config --env --set subdir osx-64 + + - name: Install weasyprint on macos-latest🍎 + if: runner.os == 'macOS' + run: | + conda install -n env-dajin2 weasyprint + + - name: Install dependencies + run: | + conda activate env-dajin2 + + # ========================================== + # Use pip because conda does not support pyproject.toml. + # ========================================== + pip install -U pip pytest + pip install -e . + + ########################################## + # Execute tests + ########################################## + + - name: Run tests version + run: sh tests/test_version.sh diff --git a/tests/test_version.sh b/tests/test_version.sh new file mode 100644 index 0000000..e337087 --- /dev/null +++ b/tests/test_version.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +PIP_VERSION=$(echo $(DAJIN2 --version) | awk '{print $NF}') +UTIL_VERSION=$(grep "DAJIN_VERSION" DAJIN2/src/DAJIN2/utils/config.py | awk '{print $NF}' | tr -d '"') + +if [ "$PIP_VERSION" != "$UTIL_VERSION" ]; then + echo "Version mismatch: $PIP_VERSION != $UTIL_VERSION" + exit 1 +fi