-
Notifications
You must be signed in to change notification settings - Fork 13
180 lines (167 loc) · 6.35 KB
/
pull-requests-tests.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: pull-request-tests
on:
push:
branches:
- master
pull_request:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/dali
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
CI: 1
RUST_BACKTRACE: short
RUSTUP_MAX_RETRIES: 10
# RUSTFLAGS_EXTRA: "-D warnings -W rust-2021-compatibility"
jobs:
test:
runs-on: ubuntu-latest
container: rust:1.74.0-alpine3.18
services:
backend:
image: nginx:latest
options: -v ${{ github.workspace }}/tests/resources/:/usr/share/nginx/html/ --name backend
steps:
- name: Debug workflow trigger
run: |
echo "The workflow was triggered by ${{ github.triggering_actor }}"
echo -e "The actor is\t${{github.actor}}"
echo -e "The actor has id\t${{github.actor_id}}"
- uses: actions/checkout@v4
- name: Restart nginx
uses: docker://docker
with:
args: docker restart backend
- name: Install build dependencies
run: apk add --update --no-cache --repository https://dl-cdn.alpinelinux.org/alpine/v3.18/main
build-base=0.5-r3
clang=16.0.6-r1
clang16-libclang=16.0.6-r1
expat-dev=2.6.4-r0
giflib-dev=5.2.2-r0
glib-dev=2.76.6-r0
lcms2-dev=2.15-r2
libexif-dev=0.6.24-r1
libheif-dev=1.16.2-r0
libimagequant-dev=4.2.0-r0
libjpeg-turbo-dev=2.1.5.1-r3
libpng-dev=1.6.44-r0
librsvg-dev=2.56.3-r0
libwebp-dev=1.3.2-r0
openssl-dev=3.1.7-r1
orc-dev=0.4.39-r0
pkgconf=1.9.5-r0
tiff-dev=4.5.1-r0
tar
curl
- name: Install Libvips
run: |
wget https://github.com/libvips/libvips/releases/download/v8.13.3/vips-8.13.3.tar.gz
mkdir /vips
tar xvzf vips-8.13.3.tar.gz -C /vips --strip-components 1
cd /vips
./configure --enable-debug=no --without-OpenEXR --disable-static --enable-silent-rule
make
make install
rm -rf vips vips-8.13.3.tar.gz
- name: Check if nginx is available for files hosting
run: curl http://backend/exif --output /dev/null
# Cache needs the Cargo.lock file for the cache key and must come after the git checkout
- name: Set up cargo cache
uses: actions/cache@v4
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Build Dali
run: RUSTFLAGS="-C target-feature=-crt-static $(pkg-config vips --libs)" cargo build
- name: Run Dali
run: ./target/debug/dali >> /dev/null &
- name: Wait for Dali to start
run: sleep 5
- name: Run tests
run: |
set +e
RUSTFLAGS="-C target-feature=-crt-static $(pkg-config vips --libs)" HTTP_HOST=backend cargo test -- --quiet
exitcode="$?"
echo "exitcode=$exitcode" >> $GITHUB_OUTPUT
exit "$exitcode"
# Only runs if a pull request is created
# ignored by renovate branch auto-commit strategy, which does not create PRs
# renovate creates merge branches and merges on test success
# if the tests fail, a PR is raised
# Only run if the tests were successful
docker-preview:
runs-on: ubuntu-latest
needs:
- test
if: ${{ !contains(needs.test.outputs.status, 'failure') }} && ${{!(github.triggering_actor == 'dependabot[bot]' || github.triggering_actor == 'renovate[bot]') && github.repository == 'olxgroup-oss/dali'}}
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
if: github.event_name == 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata for the Dali image with the reqwest feature
if: github.event_name == 'pull_request' && github.repository == 'olxgroup-oss/dali'
id: meta-reqwest
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: ${{ github.head_ref }}
- name: Build and push with the reqwest feature
if: github.event_name == 'pull_request' && github.repository == 'olxgroup-oss/dali'
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
build-args: DALI_FEATURES=reqwest
push: true
tags: ${{ steps.meta-reqwest.outputs.tags }}
labels: ${{ steps.meta-reqwest.outputs.labels }}
- name: Docker metadata for the Dali image with the s3 feature
if: github.event_name == 'pull_request' && github.repository == 'olxgroup-oss/dali'
id: meta-s3
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-s3
tags: ${{ github.head_ref }}
- name: Build and push with the s3 feature
if: github.event_name == 'pull_request' && github.repository == 'olxgroup-oss/dali'
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
build-args: DALI_FEATURES=s3
push: true
tags: ${{ steps.meta-s3.outputs.tags }}
labels: ${{ steps.meta-s3.outputs.labels }}
- name: Add package image comment to PR
if: github.event_name == 'pull_request' && github.repository == 'olxgroup-oss/dali'
uses: marocchino/sticky-pull-request-comment@v2
# Inform the user that a preview image has been built and published
with:
header: pr-docker-image
message: |
Hey there and thank you for opening this pull request! 👋🏼
You can pull a preview container image of dali with the below command:
```console
docker pull ${{ steps.meta-reqwest.outputs.tags }}
docker pull ${{ steps.meta-s3.outputs.tags }}
```