Skip to content

Commit

Permalink
Begin to setup automated tests on a cluster
Browse files Browse the repository at this point in the history
Signed-off-by: Fabrice Normandin <[email protected]>
  • Loading branch information
lebrice committed Jul 2, 2024
1 parent 6a42ef0 commit 0cfba00
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 2 deletions.
42 changes: 40 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
name: coverage-reports-unit-tests-${{ matrix.platform }}-${{ matrix.python-version }}
path: ./coverage.xml

integration_tests:
local_integration_tests:
needs: [unit_tests]
runs-on: self-hosted
strategy:
Expand Down Expand Up @@ -90,9 +90,47 @@ jobs:
name: coverage-reports-integration-tests-${{ matrix.python-version }}
path: ./coverage.xml

launch-slurm-actions-runner:
needs: [local_integration_tests]
runs-on: self-hosted
steps:
- name: Launch Slurm Actions Runner
run: ssh mila "sbatch ~/repos/ResearchTemplate/actions-runner-job.sh"

slurm_integration_tests:
needs: [local_integration_tests]
runs-on: [self-hosted, mila]
strategy:
max-parallel: 1
matrix:
python-version: ['3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: pip install pdm
- name: Install dependencies
run: pdm install

- name: Test with pytest
run: pdm run pytest -v --cov=project --cov-report=xml --cov-append

- name: Test with pytest (only slow tests)
run: pdm run pytest -v -m slow --slow --cov=project --cov-report=xml --cov-append

- name: Store coverage report as an artifact
uses: actions/upload-artifact@v4
with:
name: coverage-reports-integration-tests-${{ matrix.python-version }}
path: ./coverage.xml



# https://about.codecov.io/blog/uploading-code-coverage-in-a-separate-job-on-github-actions/
upload-coverage-codecov:
needs: [integration_tests]
needs: [local_integration_tests]
runs-on: ubuntu-latest
name: Upload coverage reports to Codecov
steps:
Expand Down
34 changes: 34 additions & 0 deletions actions-runner-job.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH --mem=16G
#SBATCH --gpus=rtx8000:1
#SBATCH --time=00:30:00
#SBATCH --dependency=singleton
#SBATCH --output=logs/runner_%j.out

set -eof pipefail

archive="actions-runner-linux-x64-2.317.0.tar.gz"
# Look for the actions-runner archive on $SCRATCH first. Download it if it doesn't exist.
if [ ! -f "$SCRATCH/$archive" ]; then
curl -o $SCRATCH/$archive \
-L "https://github.com/actions/runner/releases/download/v2.317.0/$archive"
fi
# Make a symbolic link in SLURM_TMPDIR.
ln -s $SCRATCH/$archive $SLURM_TMPDIR/$archive

cd $SLURM_TMPDIR

echo "9e883d210df8c6028aff475475a457d380353f9d01877d51cc01a17b2a91161d $archive" | shasum -a 256 -c

# Extract the installer
tar xzf ./actions-runner-linux-x64-2.317.0.tar.gz

# Create the runner and configure it programmatically
./config.sh --url https://github.com/mila-iqia/ResearchTemplate --token $TOKEN \
--unattended --replace --name mila --labels slurm-cluster --emphemeral

# Launch the actions runner.
./run.sh

0 comments on commit 0cfba00

Please sign in to comment.