-
-
Notifications
You must be signed in to change notification settings - Fork 21
120 lines (111 loc) · 3.73 KB
/
ci_servicex.yaml
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
name: Test and Build Docker Images
on:
push:
branches:
- "*"
pull_request:
workflow_call:
env:
DOCKERHUB_ORG: sslhep
jobs:
build-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout to repository
uses: actions/[email protected]
- name: Read file contents
working-directory: ./.github/workflows
id: set-matrix
run: |
echo "matrix<<EOF" >> $GITHUB_OUTPUT
cat deploy-config.json >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
test:
needs: build-matrix
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
python-version: ["3.10"]
app: "${{fromJson(needs.build-matrix.outputs.matrix)}}"
runs-on: ubuntu-22.04
steps:
- name: Checkout to repository
uses: actions/[email protected]
- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
if: ${{ matrix.app.test_required }}
- name: Install poetry
uses: abatilo/[email protected]
with:
poetry-version: 1.8.3
- name: Install dependencies
working-directory: ${{ matrix.app.dir_name }}
if: ${{ matrix.app.test_required }}
run: |
echo "${{ matrix.app }}"
poetry install --no-root --with=test
pip list
- name: Lint with Flake8
working-directory: ${{ matrix.app.dir_name }}
if: ${{ matrix.app.test_required }}
run: |
poetry run flake8
- name: Test with pytest
working-directory: ${{ matrix.app.dir_name }}
if: ${{ matrix.app.test_required }}
run: |
PYTHONPATH=src poetry run python -m coverage run -m pytest -r sx
- name: Report coverage with Codecov
if: ${{ matrix.app.test_required }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
publish:
needs: [build-matrix, test]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
app: ${{fromJson(needs.build-matrix.outputs.matrix)}}
steps:
- uses: actions/[email protected]
- name: Extract tag name
working-directory: ${{ matrix.app.dir_name }}
shell: bash
run: echo "imagetag=sslhep/${{matrix.app.image_name}}:$(echo ${GITHUB_REF##*/})" >> $GITHUB_OUTPUT
id: extract_tag_name
- name: Extract Cache Dir
working-directory: ${{ matrix.app.dir_name }}
shell: bash
run: echo "cachetag=sslhep/${{matrix.app.image_name}}:buildcache" >> $GITHUB_OUTPUT
id: extract_cache_name
- name: Print Cache Tag Name
shell: bash
run: |
echo "${{ steps.extract_cache_name.outputs.cachetag }}"
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Login to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/[email protected]
with:
context: ${{ matrix.app.dir_name }}
push: true
tags: ${{ steps.extract_tag_name.outputs.imagetag }}
cache-from: type=${{ format('registry,ref={0}',steps.extract_cache_name.outputs.cachetag) }}
cache-to: type=${{ format('registry,ref={0}',steps.extract_cache_name.outputs.cachetag) }},mode=max
file: ${{ matrix.app.dockerfile }}
platforms: linux/amd64,linux/arm64