-
Notifications
You must be signed in to change notification settings - Fork 8
69 lines (66 loc) · 1.9 KB
/
ci.yml
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
# Description
# ===========
# This workflow builds a docker image each time
# commits are pushed to GitHub or a pull request is opened.
# It also runs a container of this image to test it.
---
name: CI
# This workflow is triggered each time commits are pushed to GitHub
# and also on each pull request (on the commit that would be created
# after the merge) but is not triggered if only markdown files were edited.
on:
push:
branches:
- '*'
paths-ignore:
- '*.md'
pull_request:
branches:
- '*'
paths-ignore:
- '*.md'
# Variables to configure the workflow
env:
DOCKERFILE_PATH: '.'
DOCKERFILE_FILENAME: 'Dockerfile'
DOCKER_IMAGE_NAME: 'lequal/sonarqube-catlab'
jobs:
# Job that builds the image and upload it as an artifact
build:
name: Build the docker image
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build docker image
run: docker build -t $DOCKER_IMAGE_NAME $DOCKERFILE_PATH
- name: Save Docker image
run: docker image save -o image.tar $DOCKER_IMAGE_NAME
- name: Upload image as an artifact
uses: actions/upload-artifact@v4
with:
name: image
path: image.tar
# Job that tests the image
test:
name: Test the Docker image
runs-on: ubuntu-22.04
needs: build
steps:
- uses: actions/checkout@v4
- name: Retrieve the image
uses: actions/download-artifact@v4
with:
name: image
- name: Load the image
run: docker image load -i image.tar
- name: check image name
run: docker images
# Run the tests
- name: Test docker image
run: |
sudo sysctl -w vm.max_map_count=262144
echo -e "Results of the CI pipeline\n" > tests_logs.txt
cd tests/
python3 -m pip install -r requirements.txt
python3 -m pytest -v