forked from ssl-hep/ServiceX
-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (122 loc) · 4.26 KB
/
ci_servicex.yaml
File metadata and controls
131 lines (122 loc) · 4.26 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
121
122
123
124
125
126
127
128
129
130
131
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/checkout@v4.2.2
- 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/checkout@v4.2.2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5.6.0
with:
python-version: ${{ matrix.python-version }}
if: ${{ matrix.app.test_required }}
- name: Install poetry
uses: abatilo/actions-poetry@v4.0.0
with:
poetry-version: 2.1.1
- 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/checkout@v4.2.2
- 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/setup-qemu-action@v3.6.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.10.0
- name: Login to Docker Hub
uses: docker/login-action@v3.4.0
if: ${{ github.secret_source == 'Actions' }}
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v6.17.0
if: ${{ github.secret_source == 'Actions' }}
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
- name: Build
uses: docker/build-push-action@v6.17.0
if: ${{ github.secret_source != 'Actions' }}
with:
context: ${{ matrix.app.dir_name }}
tags: ${{ steps.extract_tag_name.outputs.imagetag }}
cache-from: type=${{ format('registry,ref={0}',steps.extract_cache_name.outputs.cachetag) }}
file: ${{ matrix.app.dockerfile }}
platforms: linux/amd64,linux/arm64