diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5d9ea4e4..3b12b5b7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -6,70 +6,124 @@ on: - master tags: - "[0-9]+.[0-9]+.[0-9]+*" - pull_request: - workflow_dispatch: jobs: - test: - runs-on: ubuntu-22.04 + unittest: + runs-on: arc-runner + env: + TOX_COMMAND: "tox --skip-missing-interpreters false" + strategy: fail-fast: false matrix: - tox-env: [py38, py39, py310, py311, py312, docs, linters, package] - include: - - tox-env: py38 - python-version: 3.8 - - tox-env: py39 - python-version: 3.9 - - tox-env: py310 - python-version: "3.10" - - tox-env: py311 - python-version: "3.11" - - tox-env: py312 - python-version: "3.12" - - tox-env: linters - python-version: "3.11" - - tox-env: package - python-version: "3.11" + toxenv: [py38, py39, py310, py311, py312, docs, linters, package] steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Install Dependencies + - name: Checkout + uses: actions/checkout@v4 + + - name: Assert PR is up-to-date + if: github.event_name == 'pull_request' run: | - python -m pip install --upgrade pip tox + git fetch origin ${{ github.base_ref }} + git fetch origin HEAD --unshallow + git_change_target_merge_base=$(git merge-base HEAD origin/${{ github.base_ref }}) + git_change_target_sha=$(git rev-parse origin/${{ github.base_ref }}) + + if [[ "${git_change_target_merge_base}" != "${git_change_target_sha}" ]]; then + echo 'Pull request is not up-to-date!' + echo "Please, rebase your pull request on top of '${{ github.base_ref }}' (commit: ${git_change_target_sha})." + exit 1 + fi + - name: Run Tests run: > - tox -e ${{ matrix.tox-env }} - - name: Upload coverage to Codecov - if: matrix.tox-env == 'py38' || matrix.tox-env == 'py39' || matrix.tox-env == 'py310' || matrix.tox-env == 'py311' || matrix.tox-env == 'py312' - uses: codecov/codecov-action@v1 + ${{ env.TOX_COMMAND }} -e ${{ matrix.toxenv }} + + e2e: + runs-on: arc-runner + needs: unittest + env: + GENESIS_POSTGRESQL_NAME: genialis-base + GENESIS_POSTGRESQL_USER: genialis-base + GENESIS_POSTGRESQL_PASSWORD: genialis-base + GENESIS_POSTGRESQL_PORT: 55434 + GENESIS_REDIS_PORT: 56381 + GENESIS_RESDK_PATH: ".." + GENESIS_REST_THROTTLING: '{"login": "100000/hour", "credentials": "100000/hour", "email": "100000/hour"}' + + services: + postgres: + image: public.ecr.aws/docker/library/postgres:14 + env: + POSTGRES_USER: genialis-base + POSTGRES_DB: genialis-base + POSTGRES_PASSWORD: genialis-base + ports: + - 55434:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + redis: + image: public.ecr.aws/docker/library/redis:7-alpine + ports: + - 56381:6379 + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - name: Checkout resolwe-bio-py + uses: actions/checkout@v4 + + - name: Checkout genialis-base + uses: actions/checkout@v4 with: - file: .coverage + repository: genialis/genialis-base + path: genialis-base + ssh-key: ${{ secrets.GHA_SSH_PRIVATE_KEY_GENIALIS_DEPLOY }} - build: - runs-on: ubuntu-22.04 + - name: Run tests + run: | + cd genialis-base - needs: test + # Prepare frontend configuration + mkdir -p frontend/genjs/schema + echo '{}' > frontend/genjs/schema/configuration.json - if: "startsWith(github.ref, 'refs/tags')" + # Make sure `python` refers to the tox environment's Python + export PATH=`pwd`/.tox/py310-e2e-resdk/bin:$PATH + tox --skip-missing-interpreters false -e py310-e2e-resdk + + build: + runs-on: arc-runner + needs: [unittest, e2e] + if: startsWith(github.ref, 'refs/tags') + env: + PYTHON: "python3.12" steps: - uses: actions/checkout@v4 - - name: Set up Python 3.11 - uses: actions/setup-python@v5 - with: - python-version: "3.11" + - name: Install build - run: python -m pip install --user build + run: ${{ env.PYTHON }} -m pip install --user build + - name: Build a binary wheel and a source tarball - run: python -m build --sdist --wheel --outdir dist/ . + run: ${{ env.PYTHON }} -m build --sdist --wheel --outdir dist/ . + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1 + with: + file: .coverage + - name: Publish distribution to PyPI - uses: pypa/gh-action-pypi-publish@master + uses: pypa/gh-action-pypi-publish@release/v1.8 with: password: ${{ secrets.pypi_password }}