forked from Cytomine-ULiege/pims
-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (88 loc) · 2.69 KB
/
test-pims.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
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
name: Test PIMS
on:
pull_request:
branches:
- master
env:
IMAGE_NAME: ${{ github.repository }}
REPORT: test-report.xml
REGISTRY: ghcr.io
jobs:
build-pims:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
tags: ${{ steps.meta.outputs.tags }}
steps:
- name: Set up the repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build pims image
uses: docker/build-push-action@v4
with:
build-args: |
ENTRYPOINT_SCRIPTS_VERSION=${{ vars.ENTRYPOINT_SCRIPTS_VERSION }}
GUNICORN_VERSION=${{ vars.GUNICORN_VERSION }}
OPENJPEG_URL=${{ vars.OPENJPEG_URL }}
OPENJPEG_VERSION=${{ vars.OPENJPEG_VERSION }}
PY_VERSION=${{ vars.PYTHON_VERSION }}
SETUPTOOLS_VERSION=${{ vars.SETUPTOOLS_VERSION }}
UBUNTU_VERSION=${{ vars.UBUNTU_VERSION }}
VIPS_URL=${{ vars.VIPS_URL }}
VIPS_VERSION=${{ vars.VIPS_VERSION }}
context: .
file: ./docker/backend.dockerfile
labels: ${{ steps.meta.outputs.labels }}
push: true
tags: ${{ steps.meta.outputs.tags }}
test-pims:
runs-on: ubuntu-latest
needs: build-pims
container:
image: ${{ needs.build-pims.outputs.tags }}
credentials:
username: ${{ github.actor }}
password: ${{ github.token }}
steps:
- name: Set up the repository
uses: actions/checkout@v3
- name: Set up pytest
run: pip install pytest
- name: Run tests
run: pytest tests --junitxml=${{ env.REPORT }}
- name: Upload tests report
uses: actions/upload-artifact@v3
with:
name: ${{ env.REPORT }}
path: ${{ env.REPORT }}
retention-days: 30
clean-pims:
runs-on: ubuntu-latest
needs:
- test-pims
steps:
- name: Delete pims test image from registry
uses: actions/github-script@v6
with:
script: |
try {
github.rest.packages.deletePackageForOrg({
org: context.repo.owner,
package_type: "container",
package_name: "pims",
});
} catch (error) {
core.setFailed(error.message);
}