From d59681284f7db7927a547c517c5b9b160e2c8f78 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 | 26 +++++++++++----------- .github/workflows/pages.yaml | 27 +++++++++-------------- .github/workflows/pre-commit.yml | 24 ++++++--------------- .github/workflows/tests.yml | 31 +++++++++++++-------------- conda-environment-dev.yml | 2 +- 5 files changed, 46 insertions(+), 64 deletions(-) diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index 130c24c30d..07cc2cbbbb 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -1,33 +1,33 @@ name: Coverage Report on: pull_request: + paths-ignore: + - "doc/**" + - "docs/**" types: [opened, reopened, synchronize] - paths: - - '**.py' jobs: pytest-coverage: runs-on: ubuntu-latest 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 mxcubecore poetry install --only=dev,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 mxcubecore pytest --cov=mxcubecore --junitxml=pytest.xml --cov-report=term-missing:skip-covered | tee pytest-coverage.txt - name: Pytest coverage comment id: coverage-comment @@ -40,7 +40,7 @@ jobs: - name: Check the output coverage run: | - echo "Coverage Percantage - ${{ steps.coverage-comment.outputs.coverage }}" + echo "Coverage Percentage - ${{ steps.coverage-comment.outputs.coverage }}" echo "Coverage Warnings - ${{ steps.coverage-comment.outputs.warnings }}" echo "Coverage Errors - ${{ steps.coverage-comment.outputs.errors }}" echo "Coverage Failures - ${{ steps.coverage-comment.outputs.failures }}" diff --git a/.github/workflows/pages.yaml b/.github/workflows/pages.yaml index 26523822ae..975835d65e 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 mxcubecore poetry install --only=docs,main" - name: "Build documentation with Sphinx" - run: | - poetry run make --directory=./docs/ html + run: "${MAMBA_EXE} run --name mxcubecore 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..ce57f804f7 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -1,4 +1,4 @@ -name: Linting & Code Quality +name: Pre-commit hooks on: pull_request: types: [opened, reopened, synchronize] @@ -6,24 +6,14 @@ jobs: pre-commit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v4 + # Python 3.8 because we want lowest supported version for syntax checks (format, lint) - name: Set up Python 3.8 - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 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 - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install poetry --user - python -m poetry install - - - name: Run Pre-Commit - run: | - poetry run pre-commit run --all-files + - name: Run pre-commit hooks + uses: pre-commit/action@v3.0.0 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index da12e51820..f92c81722b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,32 +1,31 @@ name: Pytest on: pull_request: + paths-ignore: + - "doc/**" + - "docs/**" types: [opened, reopened, synchronize] - paths: - - '**.py' jobs: Python: 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 mxcubecore poetry install --extras=tango --only=dev,main" - name: Test with pytest - run: | - python -m poetry run pytest --no-cov + run: "${MAMBA_EXE} run --name mxcubecore pytest --no-cov" diff --git a/conda-environment-dev.yml b/conda-environment-dev.yml index df5014992a..272ff38ca0 100644 --- a/conda-environment-dev.yml +++ b/conda-environment-dev.yml @@ -5,7 +5,7 @@ dependencies: - python >=3.8,<3.11 # Run-time - openldap - - python-ldap=3.4.0 + - python-ldap=3.4.3 # Dev - pip - poetry