From c7b251c8e3d0fdd99aebcd218cfe8f85ae8a0daf Mon Sep 17 00:00:00 2001 From: fabcor Date: Mon, 5 Feb 2024 12:18:40 +0100 Subject: [PATCH] Update GitHub Actions workflows Use conda environments for better consistency --- .github/workflows/coverage_report.yml | 19 +++++++++---------- .github/workflows/pages.yaml | 27 ++++++++++----------------- .github/workflows/pre-commit.yml | 23 ++++++++--------------- .github/workflows/tests.yml | 26 ++++++++++++-------------- 4 files changed, 39 insertions(+), 56 deletions(-) diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index 130c24c30d..60da2effc0 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -10,24 +10,23 @@ jobs: permissions: pull-requests: write steps: - - uses: actions/checkout@v3 + - name: Checkout code + uses: actions/checkout@v4 - - name: Set up Python 3.10 - uses: actions/setup-python@v4 + - name: Set up conda environment with micromamba + uses: mamba-org/setup-micromamba@v1 with: - python-version: "3.10" + cache-environment: true + environment-file: conda-environment-dev.yml + post-cleanup: "all" - name: Install dependencies - run: | - sudo apt-get update && sudo apt-get install -y libsasl2-dev libldap2-dev libssl-dev - python -m pip install --upgrade pip - python -m pip install poetry --user - python -m poetry install --extras=tango + run: "${MAMBA_EXE} run --name mxcubeweb poetry install --only=main --extras=tango" - name: Run and write pytest run: | set -o pipefail - poetry run pytest --cov=mxcubecore --junitxml=pytest.xml --cov-report=term-missing:skip-covered | tee pytest-coverage.txt + ${MAMBA_EXE} run --name mxcubeweb pytest --cov=mxcubecore --junitxml=pytest.xml --cov-report=term-missing:skip-covered | tee pytest-coverage.txt - name: Pytest coverage comment id: coverage-comment diff --git a/.github/workflows/pages.yaml b/.github/workflows/pages.yaml index 26523822ae..8cdb0e3eeb 100644 --- a/.github/workflows/pages.yaml +++ b/.github/workflows/pages.yaml @@ -21,31 +21,24 @@ jobs: - name: "Checkout" uses: "actions/checkout@v4" # tested with v4.1.0 - - name: "Set up Python 3.8" - uses: "actions/setup-python@v4" # tested with v4.7.0 + - name: "Setup conda environment with micromamba" + uses: "mamba-org/setup-micromamba@v1" with: - python-version: "3.8" - - - name: "Install OpenLDAP's dev package with apt" - run: | - sudo apt-get update - sudo apt-get install --no-install-recommends --yes libldap2-dev libsasl2-dev + cache-environment: true + environment-file: "conda-environment-dev.yml" + post-cleanup: "all" - name: "Install dependencies with Poetry" - run: | - python -m pip install --upgrade pip - python -m pip install poetry --user - python -m poetry install --only=docs,main + run: "${MAMBA_EXE} run --name mxcubeweb poetry install --only=docs,main" - name: "Build documentation with Sphinx" - run: | - poetry run make --directory=./docs/ html + run: "${MAMBA_EXE} run --name mxcubeweb make --directory=./docs/ html" - name: "Upload artifact for GitHub Pages" # This could potentially be run only when we intend to deploy... # ...but it can be useful to have the artifact for debugging # if: "github.ref_name == github.event.repository.default_branch" - uses: "actions/upload-pages-artifact@v2" # tested with v2.0.0 + uses: "actions/upload-pages-artifact@v3" with: path: "docs/build/html" @@ -69,11 +62,11 @@ jobs: steps: - name: "Setup GitHub Pages" - uses: "actions/configure-pages@v3" # tested with v3.0.6 + uses: "actions/configure-pages@v4" - name: "Deploy to GitHub Pages" id: "deployment" - uses: "actions/deploy-pages@v2" # tested with 2.0.4 + uses: "actions/deploy-pages@v4" ... # EOF diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 4e45084584..63bed128bb 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -6,24 +6,17 @@ jobs: pre-commit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - name: Set up Python 3.8 - uses: actions/setup-python@v4 + - name: Setup conda environment with micromamba + uses: mamba-org/setup-micromamba@v1 with: - python-version: "3.8" - - - name: Install openldap - run: | - sudo apt-get update && sudo apt-get upgrade -y - sudo apt-get install -y libldap2-dev libsasl2-dev slapd ldap-utils tox lcov valgrind + cache-environment: true + environment-file: conda-environment-dev.yml + post-cleanup: all - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install poetry --user - python -m poetry install + run: "${MAMBA_EXE} run --name mxcubeweb poetry install" - name: Run Pre-Commit - run: | - poetry run pre-commit run --all-files + run: "${MAMBA_EXE} run --name mxcubeweb pre-commit run --all-files" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index da12e51820..d61c4d350d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,24 +9,22 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10"] + python-version: ["3.8", "3.9", "3.10"] steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + - name: Setup conda environment with micromamba for Python ${{ matrix.python-version }} + uses: mamba-org/setup-micromamba@v1 with: - python-version: ${{ matrix.python-version }} - - - name: Install openldap - run: sudo apt-get update && sudo apt-get install -y libldap2-dev libsasl2-dev slapd ldap-utils tox lcov valgrind + cache-environment: true + create-args: >- + python=${{ matrix.python-version }} + environment-file: conda-environment-dev.yml + post-cleanup: all - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install poetry --user - python -m poetry install --extras=tango + run: "${MAMBA_EXE} run --name mxcubeweb poetry install --extras=tango --only=dev,main" - name: Test with pytest - run: | - python -m poetry run pytest --no-cov + run: "${MAMBA_EXE} run --name mxcubeweb pytest --no-cov"