-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (88 loc) · 3.57 KB
/
test.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
name: test
on:
push:
env:
CACHE_PATH_NGINX: '/tmp/nginx-image-save.tar'
NGINX_IMAGE_VERSION: '1.21.6'
CACHE_PATH_SCRATCH_WEB: '/tmp/scratch_web-image-save.tar'
SCRATCH_WEB_IMAGE_VERSION: 'latest'
GRM_PATH: '/tmp/git-restore-mtime.py'
CARGO_INCREMENTAL: 1
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
# Fetch all commit history for mtime
fetch-depth: 0
# Cache rust crates
# ------------------------------------------------
# Cache
- name: Cache git-restore-mtime script
id: cache-grm
uses: actions/cache@v2
with:
path: ${{ env.GRM_PATH }}
key: ${{ runner.os }}-git-restore-mtime
- name: DL if no cache hit
if: steps.cache-grm.outputs.cache-hit != 'true'
run: curl -Lo ${{ env.GRM_PATH }} "https://github.com/MestreLion/git-tools/raw/main/git-restore-mtime"
- name: Restore mtime
run: python ${{ env.GRM_PATH }}
- name: Cache rust libs
id: cache-rustlibs
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cache-rustlibs-${{ hashFiles( format('{0}{1}', github.workspace, '/Cargo.lock') ) }}
restore-keys:
${{ runner.os }}-cache-rustlibs-
# cache scratch_web docker image test
# ------------------------------------------------
- name: Cache nginx docker image
id: cache-scratchweb-test2
uses: actions/cache@v2
with:
path: ${{ env.CACHE_PATH_SCRATCH_WEB }}
key: ${{ runner.os }}-cache-scratchweb-test2-${{ env.SCRATCH_WEB_IMAGE_VERSION }}
restore-keys:
${{ runner.os }}-cache-scratchweb-test2-
- name: Load docker image from cache
if: steps.cache-scratchweb-test2.outputs.cache-hit == 'true'
run: docker load --input ${{ env.CACHE_PATH_SCRATCH_WEB }}
- name: Build scratch web server docker image
if: steps.cache-scratchweb-test2.outputs.cache-hit != 'true'
run: |
docker image build -f ci-docker/scratch_web/Dockerfile -t scratch_web ci-docker/scratch_web/
docker save --output ${{ env.CACHE_PATH_SCRATCH_WEB }} scratch_web:${{ env.SCRATCH_WEB_IMAGE_VERSION }}
# cache nginx docker image test
# ------------------------------------------------
- name: Cache nginx docker image
id: cache-nginx-test2
uses: actions/cache@v2
with:
path: ${{ env.CACHE_PATH_NGINX }}
key: ${{ runner.os }}-cache-nginx-test2-${{ env.NGINX_IMAGE_VERSION }}
restore-keys:
${{ runner.os }}-cache-nginx-test2-
- name: Load docker image from cache
if: steps.cache-nginx-test2.outputs.cache-hit == 'true'
run: docker load --input ${{ env.CACHE_PATH_NGINX }}
- name: Pull docker image and save cache
if: steps.cache-nginx-test2.outputs.cache-hit != 'true'
run: |
docker pull nginx:${{ env.NGINX_IMAGE_VERSION }}
docker save --output ${{ env.CACHE_PATH_NGINX }} nginx:${{ env.NGINX_IMAGE_VERSION }}
# start docker container
# ------------------------------------------------
- name: run scratch_web
run: docker run -d --name test_scratch_web scratch_web:${{ env.SCRATCH_WEB_IMAGE_VERSION }}
- name: run nginx
run: docker run -d --name test_nginx nginx:${{ env.NGINX_IMAGE_VERSION }}
# run test
# ------------------------------------------------
- run: cargo test