Skip to content

Commit e011652

Browse files
committed
Add cuda workflow to test cuda developments on CI
1 parent 876d7d8 commit e011652

File tree

10 files changed

+135
-14
lines changed

10 files changed

+135
-14
lines changed

.github/actions/coverage_install/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ runs:
1515
- name: Directory Creation
1616
run: |
1717
INSTALL_DIR=$(cd tests; python -c "import pyccel; print(pyccel.__path__[0])")
18-
SITE_DIR=$(python -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])')
18+
SITE_DIR=$(dirname ${INSTALL_DIR})
1919
echo -e "import coverage; coverage.process_startup()" > ${SITE_DIR}/pyccel_cov.pth
2020
echo -e "[run]\nparallel = True\nsource = ${INSTALL_DIR}\ndata_file = $(pwd)/.coverage\n[report]\ninclude = ${INSTALL_DIR}/*\n[xml]\noutput = cobertura.xml" > .coveragerc
2121
echo "SITE_DIR=${SITE_DIR}" >> $GITHUB_ENV

.github/actions/linux_install/action.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ runs:
99
shell: bash
1010
- name: Install fortran
1111
run:
12-
sudo apt-get install gfortran
12+
sudo apt-get install -y gfortran
1313
shell: bash
1414
- name: Install LaPack
1515
run:
16-
sudo apt-get install libblas-dev liblapack-dev
16+
sudo apt-get install -y libblas-dev liblapack-dev
1717
shell: bash
1818
- name: Install MPI
1919
run: |
20-
sudo apt-get install libopenmpi-dev openmpi-bin
20+
sudo apt-get install -y libopenmpi-dev openmpi-bin
2121
echo "MPI_OPTS=--oversubscribe" >> $GITHUB_ENV
2222
shell: bash
2323
- name: Install OpenMP
2424
run:
25-
sudo apt-get install libomp-dev libomp5
25+
sudo apt-get install -y libomp-dev libomp5
2626
shell: bash
2727
- name: Install Valgrind
2828
run:
29-
sudo apt-get install valgrind
29+
sudo apt-get install -y valgrind
3030
shell: bash

.github/actions/pytest_run/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ runs:
5151
working-directory: ./tests
5252
id: pytest_3
5353
- name: Test Fortran translations
54-
run: python -m pytest -n auto -rX ${FLAGS} -m "not (parallel or xdist_incompatible) and not (c or python) ${{ inputs.pytest_mark }}" --ignore=ndarrays 2>&1 | tee s4_outfile.out
54+
run: python -m pytest -n auto -rX ${FLAGS} -m "not (parallel or xdist_incompatible) and not (c or python or ccuda) ${{ inputs.pytest_mark }}" --ignore=ndarrays 2>&1 | tee s4_outfile.out
5555
shell: ${{ inputs.shell_cmd }}
5656
working-directory: ./tests
5757
id: pytest_4
5858
- name: Test multi-file Fortran translations
5959
run: |
60-
python -m pytest -rX ${FLAGS} -m "xdist_incompatible and not parallel and not (c or python) ${{ inputs.pytest_mark }}" --ignore=ndarrays 2>&1 | tee s5_outfile.out
60+
python -m pytest -rX ${FLAGS} -m "xdist_incompatible and not parallel and not (c or python or ccuda) ${{ inputs.pytest_mark }}" --ignore=ndarrays 2>&1 | tee s5_outfile.out
6161
pyccel-clean
6262
shell: ${{ inputs.shell_cmd }}
6363
working-directory: ./tests
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: 'Pyccel pytest commands generating Ccuda'
2+
inputs:
3+
shell_cmd:
4+
description: 'Specifies the shell command (different for anaconda)'
5+
required: false
6+
default: "bash"
7+
8+
runs:
9+
using: "composite"
10+
steps:
11+
- name: Ccuda tests with pytest
12+
run: |
13+
# Catch exit 5 (no tests found)
14+
sh -c 'python -m pytest -n auto -rx -m "not (parallel or xdist_incompatible) and ccuda" --ignore=symbolic --ignore=ndarrays; ret=$?; [ $ret = 5 ] && exit 0 || exit $ret'
15+
pyccel-clean
16+
shell: ${{ inputs.shell_cmd }}
17+
working-directory: ./tests
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: 'Python installation commands'
2+
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Install python
7+
run:
8+
sudo apt-get -y install python3-dev
9+
shell: bash
10+
- name: python as python3
11+
run:
12+
sudo apt-get -y install python-is-python3
13+
shell: bash
14+
- name: Install Pip
15+
run:
16+
sudo apt-get -y install python3-pip
17+
shell: bash

.github/workflows/cuda.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Cuda unit tests
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
python_version:
7+
required: false
8+
type: string
9+
ref:
10+
required: false
11+
type: string
12+
check_run_id:
13+
required: false
14+
type: string
15+
pr_repo:
16+
required: false
17+
type: string
18+
push:
19+
branches: [devel, main]
20+
21+
env:
22+
COMMIT: ${{ inputs.ref || github.event.ref }}
23+
PEM: ${{ secrets.BOT_PEM }}
24+
GITHUB_RUN_ID: ${{ github.run_id }}
25+
GITHUB_CHECK_RUN_ID: ${{ inputs.check_run_id }}
26+
PR_REPO: ${{ inputs.pr_repo || github.repository }}
27+
28+
jobs:
29+
Cuda:
30+
31+
runs-on: ubuntu-20.04
32+
name: Unit tests
33+
34+
container: nvidia/cuda:11.7.1-devel-ubuntu20.04
35+
steps:
36+
- uses: actions/checkout@v3
37+
with:
38+
ref: ${{ env.COMMIT }}
39+
repository: ${{ env.PR_REPO }}
40+
- name: Prepare docker
41+
run: |
42+
apt update && apt install sudo
43+
TZ=Europe/France
44+
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
45+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata
46+
shell: bash
47+
- name: Install python (setup-python action doesn't work with containers)
48+
uses: ./.github/actions/python_install
49+
- name: "Setup"
50+
id: token
51+
run: |
52+
pip install jwt requests
53+
python ci_tools/setup_check_run.py cuda
54+
- name: CUDA Version
55+
run: nvcc --version # cuda install check
56+
- name: Install dependencies
57+
uses: ./.github/actions/linux_install
58+
- name: Install Pyccel with tests
59+
run: |
60+
PATH=${PATH}:$HOME/.local/bin
61+
echo "PATH=${PATH}" >> $GITHUB_ENV
62+
python -m pip install --upgrade pip
63+
python -m pip install --user .[test]
64+
shell: bash
65+
- name: Coverage install
66+
uses: ./.github/actions/coverage_install
67+
- name: Ccuda tests with pytest
68+
id: cuda_pytest
69+
uses: ./.github/actions/pytest_run_cuda
70+
- name: Collect coverage information
71+
continue-on-error: True
72+
uses: ./.github/actions/coverage_collection
73+
- name: Save code coverage report
74+
uses: actions/upload-artifact@v3
75+
with:
76+
name: coverage-artifact
77+
path: .coverage
78+
retention-days: 1
79+
- name: "Post completed"
80+
if: always()
81+
run:
82+
python ci_tools/complete_check_run.py ${{ steps.cuda_pytest.outcome }}
83+

ci_tools/bot_messages/show_tests.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ The following is a list of keywords which can be used to run tests. Tests in bol
22
- **linux** : Runs the unit tests on a Linux system.
33
- **windows** : Runs the unit tests on a Windows system.
44
- **macosx** : Runs the unit tests on a MacOS X system.
5+
- **cuda** : Runs the cuda unit tests on a Linux system.
56
- **coverage** : Runs the unit tests on a Linux system and checks the coverage of the tests.
67
- **docs** : Checks if the documentation follows the numpydoc format.
78
- **pylint** : Runs pylint on files which are too big to be handled by codacy.

ci_tools/bot_tools/bot_funcs.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
'pyccel_lint': '3.8',
2424
'pylint': '3.8',
2525
'spelling': '3.8',
26-
'windows': '3.8'
26+
'windows': '3.8',
27+
'cuda': '-'
2728
}
2829

2930
test_names = {
@@ -40,15 +41,16 @@
4041
'pyccel_lint': "Pyccel best practices",
4142
'pylint': "Python linting",
4243
'spelling': "Spelling verification",
43-
'windows': "Unit tests on Windows"
44+
'windows': "Unit tests on Windows",
45+
'cuda': "Unit tests on Linux with cuda"
4446
}
4547

46-
test_dependencies = {'coverage':['linux']}
48+
test_dependencies = {'coverage':['linux', 'cuda']}
4749

4850
tests_with_base = ('coverage', 'docs', 'pyccel_lint', 'pylint')
4951

5052
pr_test_keys = ('linux', 'windows', 'macosx', 'coverage', 'docs', 'pylint',
51-
'pyccel_lint', 'spelling')
53+
'pyccel_lint', 'spelling', 'cuda')
5254

5355
review_stage_labels = ["needs_initial_review", "Ready_for_review", "Ready_to_merge"]
5456

@@ -420,7 +422,7 @@ def is_test_required(self, commit_log, name, key, state):
420422
True if the test should be run, False otherwise.
421423
"""
422424
print("Checking : ", name, key)
423-
if key in ('linux', 'windows', 'macosx', 'anaconda_linux', 'anaconda_windows', 'intel'):
425+
if key in ('linux', 'windows', 'macosx', 'anaconda_linux', 'anaconda_windows', 'intel', 'cuda'):
424426
has_relevant_change = lambda diff: any((f.startswith('pyccel/') or f.startswith('tests/')) #pylint: disable=unnecessary-lambda-assignment
425427
and f.endswith('.py') and f != 'pyccel/version.py'
426428
for f in diff)

ci_tools/devel_branch_tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
bot.run_tests(['anaconda_linux'], '3.10', force_run = True)
1616
bot.run_tests(['anaconda_windows'], '3.10', force_run = True)
1717
bot.run_tests(['intel'], '3.9', force_run = True)
18+
bot.run_tests(['cuda'], '-', force_run = True)

ci_tools/json_pytest_output.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def mini_md_summary(title, outcome, failed_tests):
6161
summary = ""
6262

6363
failed_pattern = re.compile(r".*FAILED.*")
64-
languages = ('c', 'fortran', 'python')
64+
languages = ('c', 'fortran', 'python', 'cuda')
6565
pattern = {lang: re.compile(r".*\["+lang+r"\]\ \_.*") for lang in languages}
6666

6767
for i in p_args.tests:

0 commit comments

Comments
 (0)