-
Notifications
You must be signed in to change notification settings - Fork 2
120 lines (99 loc) · 3.2 KB
/
ci.yml
File metadata and controls
120 lines (99 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# ./.github/workflows/ci.yml
name: CI
permissions:
contents: read
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.13'
cache: 'pip'
- name: Install dependencies
run: python -m pip install -e ".[dev]"
- name: Lint
run: make lint
unit:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: python -m pip install -e ".[dev]"
- name: Run smoke tests
run: make test-unit
integration:
runs-on: ubuntu-latest
needs:
- lint
- unit
strategy:
fail-fast: false
matrix:
include:
- python-version: '3.9'
moodle-image: erseco/alpine-moodle:v4.5.5
moodle-label: Moodle 4.5.5
moodle-cache-key: moodle-4-5-5
run-examples: false
- python-version: '3.13'
moodle-image: erseco/alpine-moodle:v5.0.1
moodle-label: Moodle 5.0.1
moodle-cache-key: moodle-5-0-1
run-examples: true
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: python -m pip install -e ".[dev]"
- name: Cache Docker images
uses: actions/cache@v5
with:
path: /tmp/docker-cache/${{ matrix.moodle-cache-key }}
key: ${{ runner.os }}-docker-${{ matrix.moodle-cache-key }}-${{ hashFiles('docker-compose.yml') }}
- name: Load cached Docker images
run: |
if [ -f /tmp/docker-cache/${{ matrix.moodle-cache-key }}/postgres.tar ]; then
docker load -i /tmp/docker-cache/${{ matrix.moodle-cache-key }}/postgres.tar
fi
if [ -f /tmp/docker-cache/${{ matrix.moodle-cache-key }}/moodle.tar ]; then
docker load -i /tmp/docker-cache/${{ matrix.moodle-cache-key }}/moodle.tar
fi
- name: Start ${{ matrix.moodle-label }} with Docker Compose
run: MOODLE_DOCKER_IMAGE="${{ matrix.moodle-image }}" make upd
- name: Run tests
run: make test-local
- name: Run example_script.py
if: matrix.run-examples
run: python example_script.py
- name: Save Docker images to cache
if: always()
run: |
mkdir -p /tmp/docker-cache/${{ matrix.moodle-cache-key }}
docker save postgres:16-alpine -o /tmp/docker-cache/${{ matrix.moodle-cache-key }}/postgres.tar
docker save "${{ matrix.moodle-image }}" -o /tmp/docker-cache/${{ matrix.moodle-cache-key }}/moodle.tar