Skip to content

Commit e750b73

Browse files
committed
Unifying CI files and re-using PR ci for nightly
1 parent 02ce4de commit e750b73

8 files changed

Lines changed: 232 additions & 560 deletions

File tree

.github/workflows/build-backend.yml

Lines changed: 0 additions & 61 deletions
This file was deleted.

.github/workflows/build-python-client.yml

Lines changed: 0 additions & 91 deletions
This file was deleted.
Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
# https://docs.github.com/en/actions/using-workflows/reusing-workflows#calling-a-reusable-workflow
2+
# https://docs.github.com/fr/actions/using-workflows/workflow-syntax-for-github-actions#exemple--inclusion-de-chemins-dacc%C3%A8s
3+
4+
name: Full CI
5+
on:
6+
push:
7+
branches:
8+
- main
9+
pull_request:
10+
workflow_dispatch:
11+
inputs:
12+
run-integ:
13+
description: 'If integ test should be run'
14+
required: true
15+
type: boolean
16+
default: false
17+
workflow_call:
18+
inputs:
19+
run-integ:
20+
description: 'If integ test should be run'
21+
required: true
22+
type: boolean
23+
default: false
24+
env:
25+
GSK_DISABLE_ANALYTICS: true
26+
defaults:
27+
run:
28+
shell: bash
29+
jobs:
30+
pre-check:
31+
name: Pre check
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@v4
36+
with:
37+
fetch-depth: 0
38+
# Inspired from https://blog.pantsbuild.org/skipping-github-actions-jobs-without-breaking-branch-protection/
39+
- id: files
40+
name: Get changed files outside python-client
41+
uses: tj-actions/changed-files@v39
42+
with:
43+
files_ignore: python-client/**
44+
45+
- id: files-python
46+
name: Get changed files in python-client
47+
uses: tj-actions/changed-files@v39
48+
with:
49+
files: python-client/**
50+
51+
- id: python_only
52+
if: steps.files.outputs.any_changed != 'true'
53+
name: Check for changes in python only
54+
run: echo 'python_only=PYTHON_ONLY' >> $GITHUB_OUTPUT
55+
56+
- id: python_at_least
57+
if: steps.files-python.outputs.any_changed != 'true'
58+
name: Check for changes in python
59+
run: echo 'python_at_least=PYTHON_AT_LEAST' >> $GITHUB_OUTPUT
60+
61+
sonar:
62+
if: ${{ github.actor != 'dependabot[bot]' && (github.event_name == 'pull_request' || github.event_name == 'push') }}
63+
name: Sonar
64+
runs-on: ubuntu-latest
65+
steps:
66+
- name: Checkout code
67+
uses: actions/checkout@v4
68+
with:
69+
fetch-depth: 0
70+
71+
- name: Set up JDK 17
72+
uses: actions/setup-java@v3
73+
with:
74+
distribution: temurin
75+
java-version: 17
76+
77+
- name: Setup Gradle # To cache ~/.gradle
78+
uses: gradle/gradle-build-action@v2
79+
with:
80+
cache-read-only: false
81+
82+
- name: Cache SonarQube packages
83+
uses: actions/cache@v3
84+
with:
85+
path: ~/.sonar/cache
86+
key: ${{ runner.os }}-sonar
87+
88+
- name: Analyze with Sonar
89+
env:
90+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
91+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
92+
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
93+
run: ./gradlew sonar --info --parallel
94+
95+
build:
96+
needs: pre-check
97+
if: ${{ needs.pre-check.outputs.python_only != 'PYTHON_ONLY' }}
98+
name: Backend
99+
runs-on: ubuntu-latest
100+
steps:
101+
- name: Checkout code
102+
uses: actions/checkout@v4
103+
with:
104+
fetch-depth: 0
105+
106+
- name: Set up JDK 17
107+
uses: actions/setup-java@v3
108+
with:
109+
distribution: temurin
110+
java-version: 17
111+
112+
- name: Setup Gradle # To cache ~/.gradle
113+
uses: gradle/gradle-build-action@v2
114+
with:
115+
cache-read-only: false
116+
117+
- name: Cache Frontend dependencies
118+
uses: actions/cache@v3
119+
with:
120+
path: frontend/node_modules
121+
key: ${{ runner.os }}-frontend-${{ hashFiles('frontend/package-lock.json')}}
122+
restore-keys: ${{ runner.os }}-frontend
123+
124+
- uses: actions/setup-node@v3
125+
with:
126+
node-version: 16
127+
128+
- name: Build frontend
129+
run: ./gradlew :frontend:build
130+
131+
- name: Build backend
132+
run: ./gradlew :backend:build --info --parallel
133+
134+
- name: Unit test
135+
run: ./gradlew :backend:test :backend:jacocoTestReport --info --parallel
136+
137+
- name: Integration tests
138+
run: ./gradlew :backend:integrationTest --info --parallel
139+
140+
# Integration Test using postgresql using test-container
141+
- uses: docker-practice/actions-setup-docker@master
142+
if: ${{ inputs.run-integ }}
143+
144+
- name: Integration test under emulated production env
145+
if: ${{ inputs.run-integ }}
146+
run: ./gradlew :backend:integrationTest --info -Ptestcontainers
147+
148+
build-python:
149+
name: Build Python
150+
needs: pre-check
151+
if: ${{ needs.pre-check.outputs.python_at_least != 'PYTHON_AT_LEAST' }}
152+
runs-on: ${{ matrix.os }}
153+
strategy:
154+
fail-fast: false # Do not stop when any job fails
155+
matrix:
156+
python-version: [ "3.8", "3.9", "3.10" ]
157+
os: [ubuntu-latest]
158+
experimental: [false]
159+
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
160+
include:
161+
- python-version: "3.10"
162+
os: windows-2019
163+
experimental: false
164+
continue-on-error: ${{ matrix.experimental }} # https://ncorti.com/blog/howto-github-actions-build-matrix
165+
steps:
166+
- name: Checkout code
167+
uses: actions/checkout@v3.3.0
168+
169+
- name: Cache Python deps
170+
uses: actions/cache@v3
171+
with:
172+
path: python-client/.venv
173+
key: ${{ matrix.os }}-${{ matrix.python-version }}-python-deps-${{ hashFiles('python-client/tests/fixtures/**/*py')}}
174+
restore-keys: ${{ matrix.os }}-${{ matrix.python-version }}-python-deps
175+
176+
- name: Setup PDM
177+
uses: pdm-project/setup-pdm@v3
178+
with:
179+
python-version: ${{ matrix.python-version }}
180+
cache: false # TODO(Bazire): https://linear.app/giskard/issue/GSK-1712/activate-cache-on-pdm-setup-in-github-action
181+
182+
- name: Set up Pandoc (needed for python-client doc)
183+
uses: r-lib/actions/setup-pandoc@v2
184+
with:
185+
pandoc-version: '3.1.7' # https://github.com/jgm/pandoc/releases
186+
187+
- name: Cache Giskard test resources
188+
uses: actions/cache@v3
189+
with:
190+
path: ~/.giskard
191+
key: ${{ matrix.os }}-${{ matrix.python-version }}-python-test-resources-${{ hashFiles('python-client/tests/fixtures/**/*py')}}
192+
restore-keys: ${{ matrix.os }}-${{ matrix.python-version }}-python-giskard-test-resources
193+
194+
- name: Install dependencies
195+
working-directory: python-client
196+
run: pdm install -G :all
197+
198+
- name: Lint code
199+
working-directory: python-client
200+
run: pdm run lint
201+
202+
- name: Test code
203+
working-directory: python-client
204+
env:
205+
PYTEST_XDIST_AUTO_NUM_WORKERS: ${{ matrix.os == 'windows-2019' && 1 || 2 }}
206+
run: pdm run test-fast
207+
208+
- name: Build doc
209+
if : ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'}}
210+
working-directory: python-client
211+
run: pdm run doc
212+
213+
- name: Build
214+
working-directory: python-client
215+
run: pdm build
216+
217+
- name: "Python client: archive built artifacts"
218+
if: ${{ github.event.event_name == 'push' && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' }}
219+
uses: actions/upload-artifact@v3
220+
with:
221+
path: python-client/dist/*whl
222+
223+
- name: Test integ for python
224+
if: ${{ inputs.run-integ }}
225+
working-directory: python-client
226+
env:
227+
PYTEST_XDIST_AUTO_NUM_WORKERS: ${{ matrix.os == 'windows-2019' && 1 || 2 }}
228+
run: pdm run test

0 commit comments

Comments
 (0)