From 47a51d13446bf23449436f8e4bc506756479c3c8 Mon Sep 17 00:00:00 2001 From: Henrik Kjedsberg Date: Sun, 5 May 2024 22:31:39 +0200 Subject: [PATCH 1/2] Update ci --- .github/workflows/check_and_test_package.yml | 29 +++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/.github/workflows/check_and_test_package.yml b/.github/workflows/check_and_test_package.yml index 254405c7..4587f740 100644 --- a/.github/workflows/check_and_test_package.yml +++ b/.github/workflows/check_and_test_package.yml @@ -24,22 +24,27 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.8' - - name: Upgrade pip and setuptools - run: python3 -m pip install pip setuptools --upgrade + - name: Install dependencies + run: python -m pip install --upgrade pip setuptools - name: Install types-paramiko - run: python3 -m pip install types-paramiko + run: python -m pip install types-paramiko - name: Install VaMPy - run: python3 -m pip install .[test] + run: python -m pip install .[test] - name: Check code with Flake8 - run: python3 -m flake8 + run: python -m flake8 - name: Check code with mypy - run: python3 -m mypy + run: python -m mypy test-code: needs: check-code @@ -65,9 +70,13 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Upgrade pip and setuptools - run: | - python3 -m pip install pip setuptools --upgrade + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.8' + + - name: Install dependencies + run: python -m pip install --upgrade pip setuptools # See: https://github.com/marketplace/actions/setup-miniconda - name: Setup Mambaforge From 2c5b52483dc5b4305d5693acbc95d1fc6a0575dd Mon Sep 17 00:00:00 2001 From: Henrik Kjedsberg Date: Sun, 5 May 2024 22:46:55 +0200 Subject: [PATCH 2/2] Refactor CI --- .github/workflows/check_and_test_package.yml | 74 ++++++-------------- 1 file changed, 22 insertions(+), 52 deletions(-) diff --git a/.github/workflows/check_and_test_package.yml b/.github/workflows/check_and_test_package.yml index 4587f740..d78b381e 100644 --- a/.github/workflows/check_and_test_package.yml +++ b/.github/workflows/check_and_test_package.yml @@ -1,18 +1,14 @@ -name: CI +name: VaMPy CI on: push: - # The CI is executed on every push on every branch branches: - master pull_request: - # The CI is executed on every pull request to the main branch branches: - master - schedule: - # The CI is executed every day at 8am - - cron: "0 8 * * *" + - cron: '0 8 * * *' env: CACHE_NUMBER: 11 # Increase to reset cache @@ -23,28 +19,18 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: '3.8' - - name: Install dependencies - run: python -m pip install --upgrade pip setuptools - - - name: Install types-paramiko - run: python -m pip install types-paramiko + - name: Install dependencies and VaMPy + run: | + python -m pip install --upgrade pip setuptools + python -m pip install types-paramiko .[test] - - name: Install VaMPy - run: python -m pip install .[test] - - - name: Check code with Flake8 - run: python -m flake8 - - - name: Check code with mypy - run: python -m mypy + - run: python -m flake8 + - run: python -m mypy test-code: needs: check-code @@ -57,29 +43,17 @@ jobs: - os: macos-latest label: osx-64 prefix: /Users/runner/miniconda3/envs/vampy - name: Test VaMPy on ${{ matrix.label }} runs-on: ${{ matrix.os }} - - # https://github.com/marketplace/actions/setup-miniconda#use-a-default-shell defaults: - run: + run: # https://github.com/marketplace/actions/setup-miniconda#use-a-default-shell shell: bash -l {0} - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v5 + - uses: actions/checkout@v3 + - uses: actions/setup-python@v5 with: python-version: '3.8' - - - name: Install dependencies - run: python -m pip install --upgrade pip setuptools - - # See: https://github.com/marketplace/actions/setup-miniconda - - name: Setup Mambaforge + - name: Setup and install with Mambaforge uses: conda-incubator/setup-miniconda@v2 with: miniforge-variant: Mambaforge @@ -87,27 +61,23 @@ jobs: channels: conda-forge activate-environment: vampy use-mamba: true - - - name: Set cache date - run: echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV - + environment-file: environment-test.yml + id: mamba - uses: actions/cache@v2 with: path: ${{ matrix.prefix }} - key: ${{ matrix.label }}-conda-${{ hashFiles('environment-test.yml') }}-${{ env.DATE }}-${{ env.CACHE_NUMBER }} - id: cache - - - name: Update environment - run: mamba env update -n vampy -f environment-test.yml + key: ${{ matrix.label }}-${{ github.run_id }}-${{ env.CACHE_NUMBER }} + restore-keys: ${{ matrix.label }}- + - run: mamba env update -n vampy -f environment-test.yml if: steps.cache.outputs.cache-hit != 'true' - name: Install VaMPy - run: python3 -m pip install --editable .[test] + run: python -m pip install .[test] - name: Run tests - run: python3 -m pytest tests + run: python -m pytest tests - - name: Upload coverage report to codecov + - name: Upload coverage report to Codecov if: matrix.os == 'ubuntu-latest' uses: codecov/codecov-action@v3 with: