-
Notifications
You must be signed in to change notification settings - Fork 33
executable file
·141 lines (130 loc) · 4.16 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
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
132
133
134
135
136
137
138
139
140
141
# Run nose tests and CUBE integration tests.
# If both pass, build a multi-architectural docker image and push
# it to Dockerhub. When the git ref is tagged, the docker image
# will be tagged by the same name.
name: ci
on:
push:
branches: [ master ]
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
pull_request:
branches: [ master ]
jobs:
test-python:
name: unit tests
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install
run: |
pip install -r requirements/local.txt
pip install -e .
- name: Pytest
run: pytest --color=yes
test-docker:
name: tests (docker, podman)
runs-on: ubuntu-22.04
strategy:
matrix:
engine:
- docker
- podman
steps:
- uses: actions/checkout@v4
- name: Test
run: |
# podman is not configured to allow the Github Actions user to set CPU limits, so we need to ignore them.
# https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error
if [ '${{ matrix.engine }}' = 'podman' ]; then
export IGNORE_LIMITS=yes
fi
./test_docker.sh '${{ matrix.engine }}'
test-swarm:
name: tests (swarm)
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- run: ./test_swarm.sh
test-cube:
name: tests (integration)
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- run: docker build -t fnndsc/pman .
- uses: FNNDSC/cube-integration-action@master
build:
needs: [test-python, test-docker, test-swarm, test-cube]
if: github.event_name == 'push' || github.event_name == 'release'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Get build version
id: version
run: |
desc="$(git describe --tags)"
echo "Version=$desc"
echo "desc=$desc" >> $GITHUB_OUTPUT
- name: Get build tags
id: info
shell: python
run: |
import os
import datetime
import itertools
import subprocess as sp
short_sha = os.getenv('GITHUB_SHA', 'unknown')[:7]
git_refs = []
if os.getenv('GITHUB_REF', '').startswith('refs/tags/v'):
version_from_tag = os.getenv('GITHUB_REF')[11:]
git_refs.append(version_from_tag.replace('+', '.'))
registries = ['docker.io', 'ghcr.io']
repo = os.environ['GITHUB_REPOSITORY'].lower()
tags = ['latest'] + git_refs
names = ','.join(''.join(c) for c in itertools.product(
(r + '/' for r in registries),
[repo],
(':' + t for t in tags)
))
with open(os.getenv('GITHUB_OUTPUT'), 'a') as f:
f.write(f'tags={names}\n')
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
id: buildx
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
build-args: |
ENVIRONMENT=production
BUILD_VERSION=${{ steps.version.outputs.desc }}
push: true
context: .
file: ./Dockerfile
tags: "${{ steps.info.outputs.tags }}"
platforms: linux/amd64,linux/ppc64le,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Update Docker Hub description
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
short-description: ChRIS compute resource job dispatcher
readme-filepath: ./README.md
repository: fnndsc/pman