|
1 | 1 | name: PySlurm |
2 | | -on: [push, pull_request] |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + workflow_dispatch: |
| 9 | + |
3 | 10 | jobs: |
4 | | - Build: |
5 | | - runs-on: ubuntu-20.04 |
| 11 | + unit-tests: |
| 12 | + runs-on: ubuntu-latest |
6 | 13 | strategy: |
7 | 14 | matrix: |
8 | | - python-version: |
9 | | - - "3.6" |
10 | | - - "3.7" |
11 | | - - "3.8" |
12 | | - - "3.9" |
| 15 | + python-version: ["3.12"] |
13 | 16 | fail-fast: false |
14 | 17 | steps: |
15 | | - - name: Checkout repository code |
16 | | - uses: actions/checkout@v2 |
17 | | - - name: Set up Python ${{ matrix.python-version }} |
18 | | - uses: actions/setup-python@v2 |
19 | | - with: |
20 | | - python-version: ${{ matrix.python-version }} |
21 | | - - name: Install Dependencies |
| 18 | + - name: Checkout repository |
| 19 | + uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Pull Slurm container |
| 22 | + run: docker pull giovtorres/slurm-docker:25.11.2 |
| 23 | + |
| 24 | + - name: Start Slurm container |
| 25 | + run: docker compose -f docker-compose-github.yml up -d |
| 26 | + |
| 27 | + - name: Wait for Slurm services |
22 | 28 | run: | |
23 | | - which python |
24 | | - which python${{ matrix.python-version }} |
25 | | - python${{ matrix.python-version }} -m pip install --upgrade pip |
26 | | - python${{ matrix.python-verison }} -m pip install pipenv |
27 | | - pipenv --python ${{matrix.python-version }} install --dev --skip-lock |
28 | | - - name: Start Slurm Container |
29 | | - uses: sudo-bot/action-docker-compose@latest |
30 | | - with: |
31 | | - cli-args: "-f docker-compose-github.yml up -d" |
32 | | - env: |
33 | | - PYTHON: ${{ matrix.python-version }} |
34 | | - - name: Debug |
| 29 | + echo "Waiting for Slurm controller..." |
| 30 | + for i in $(seq 1 30); do |
| 31 | + if docker exec slurmctl scontrol ping 2>/dev/null | grep -q "UP"; then |
| 32 | + echo "Slurm controller is ready" |
| 33 | + break |
| 34 | + fi |
| 35 | + echo "Attempt $i/30..." |
| 36 | + sleep 2 |
| 37 | + done |
| 38 | +
|
| 39 | + echo "Waiting for compute nodes..." |
| 40 | + for i in $(seq 1 30); do |
| 41 | + if docker exec slurmctl sinfo -h -o "%T %D" 2>/dev/null | grep -q "idle"; then |
| 42 | + echo "Compute nodes are ready" |
| 43 | + break |
| 44 | + fi |
| 45 | + echo "Attempt $i/30..." |
| 46 | + sleep 2 |
| 47 | + done |
| 48 | + docker exec slurmctl sinfo |
| 49 | +
|
| 50 | + - name: Build and install PySlurm |
35 | 51 | run: | |
36 | | - docker ps -a |
37 | | - docker version |
38 | | - pwd |
39 | | - ls -al |
40 | | - docker inspect slurmctl |
41 | | - env | sort |
42 | | - - name: Build/Install/Test PySlurm |
| 52 | + docker exec slurmctl bash -c " |
| 53 | + python3 -m venv /opt/pyslurm-venv |
| 54 | + source /opt/pyslurm-venv/bin/activate |
| 55 | + pip install -r /pyslurm/test_requirements.txt |
| 56 | + cd /pyslurm |
| 57 | + python setup.py build -j4 |
| 58 | + python setup.py install |
| 59 | + " |
| 60 | +
|
| 61 | + - name: Run unit tests |
43 | 62 | run: | |
44 | | - pipenv run pytest -sv scripts/run_tests_in_container.py |
45 | | - env: |
46 | | - PYTHON: ${{ matrix.python-version }} |
| 63 | + docker exec slurmctl bash -c " |
| 64 | + source /opt/pyslurm-venv/bin/activate |
| 65 | + cd /pyslurm |
| 66 | + pytest tests/unit -v |
| 67 | + " |
47 | 68 |
|
| 69 | + integration-tests: |
| 70 | + runs-on: ubuntu-latest |
| 71 | + needs: unit-tests |
| 72 | + strategy: |
| 73 | + matrix: |
| 74 | + python-version: ["3.12"] |
| 75 | + fail-fast: false |
| 76 | + steps: |
| 77 | + - name: Checkout repository |
| 78 | + uses: actions/checkout@v4 |
| 79 | + |
| 80 | + - name: Pull Slurm container |
| 81 | + run: docker pull giovtorres/slurm-docker:25.11.2 |
| 82 | + |
| 83 | + - name: Start Slurm container |
| 84 | + run: docker compose -f docker-compose-github.yml up -d |
| 85 | + |
| 86 | + - name: Wait for Slurm services |
| 87 | + run: | |
| 88 | + echo "Waiting for Slurm controller..." |
| 89 | + for i in $(seq 1 30); do |
| 90 | + if docker exec slurmctl scontrol ping 2>/dev/null | grep -q "UP"; then |
| 91 | + echo "Slurm controller is ready" |
| 92 | + break |
| 93 | + fi |
| 94 | + echo "Attempt $i/30..." |
| 95 | + sleep 2 |
| 96 | + done |
| 97 | +
|
| 98 | + echo "Waiting for compute nodes..." |
| 99 | + for i in $(seq 1 30); do |
| 100 | + if docker exec slurmctl sinfo -h -o "%T %D" 2>/dev/null | grep -q "idle"; then |
| 101 | + echo "Compute nodes are ready" |
| 102 | + break |
| 103 | + fi |
| 104 | + echo "Attempt $i/30..." |
| 105 | + sleep 2 |
| 106 | + done |
| 107 | + docker exec slurmctl sinfo |
| 108 | +
|
| 109 | + - name: Build and install PySlurm |
| 110 | + run: | |
| 111 | + docker exec slurmctl bash -c " |
| 112 | + python3 -m venv /opt/pyslurm-venv |
| 113 | + source /opt/pyslurm-venv/bin/activate |
| 114 | + pip install -r /pyslurm/test_requirements.txt |
| 115 | + cd /pyslurm |
| 116 | + python setup.py build -j4 |
| 117 | + python setup.py install |
| 118 | + " |
| 119 | +
|
| 120 | + - name: Run integration tests |
| 121 | + run: | |
| 122 | + docker exec slurmctl bash -c " |
| 123 | + source /opt/pyslurm-venv/bin/activate |
| 124 | + cd /pyslurm |
| 125 | + pytest tests/integration -v |
| 126 | + " |
0 commit comments