-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (129 loc) · 4.23 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
# On push: build latest images and run examples
name: CI
on:
push:
branches: [ master ]
tags:
- "v?[0-9]+.[0-9]+.[0-9]+*"
pull_request:
jobs:
test:
name: test
runs-on: ubuntu-22.04
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Get examples
run: ./get_examples.sh examples
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
id: rust-toolchain
- name: Setup rust cache
uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ steps.rust-toolchain.outputs.cachekey }}
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Run tests
id: test
run: cargo llvm-cov --lcov --output-path lcov.info
continue-on-error: true
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./lcov.info
fail_ci_if_error: true
- name: End test
run: '[ "${{ steps.test.outcome }}" = "success" ]'
build:
name: Build
needs: [ test ]
runs-on: ubuntu-22.04
steps:
- name: Get git tag
id: git_info
if: startsWith(github.ref, 'refs/tags/')
run: echo "tag=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
- name: Get project info
id: determine
env:
git_tag: ${{ steps.git_info.outputs.tag }}
run: |
repo="${GITHUB_REPOSITORY,,}" # to lower case
# if build triggered by tag, use tag name
tag="${git_tag:-latest}"
# if tag is a version number prefixed by 'v', remove the 'v'
if [[ "$tag" =~ ^v[0-9].* ]]; then
tag="${tag:1}"
fi
dock_image=$repo:$tag
echo $dock_image
echo "dock_image=$dock_image" >> $GITHUB_OUTPUT
echo "repo=$repo" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3
# QEMU is used for non-x86_64 builds
- uses: docker/setup-qemu-action@v2
# buildx adds additional features to docker build
- uses: docker/setup-buildx-action@v2
with:
driver-opts: network=host
# improve rebuild speeds
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('Cargo.toml', 'Cargo.lock') }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build image
uses: docker/build-push-action@v3
id: docker_build
with:
context: .
file: ./Dockerfile
tags: localhost/${{ steps.determine.outputs.dock_image }}
load: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
build-args: |
CARGO_TERM_COLOR=always
- name: Integration tests
run: echo "no tests"
- name: Login to DockerHub
if: github.event_name == 'push' || github.event_name == 'release'
id: dockerhub_login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Login to GitHub Container Registry
if: github.event_name == 'push' || github.event_name == 'release'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push images
if: github.event_name == 'push' || github.event_name == 'release'
uses: docker/build-push-action@v3
id: docker_push
with:
context: .
file: ./Dockerfile
tags: |
docker.io/${{ steps.determine.outputs.dock_image }}
ghcr.io/${{ steps.determine.outputs.dock_image }}
platforms: linux/amd64
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
build-args: |
CARGO_TERM_COLOR=always
- name: Update DockerHub description
if: steps.docker_push.outcome == 'success'
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
short-description: A storescp DICOM instance handler for the pypx+pfdcm+ChRIS ecosystem.