-
Notifications
You must be signed in to change notification settings - Fork 0
143 lines (123 loc) · 4.52 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
142
143
name: CI
on: push
env:
DOCKER_CACHE_PATH: ${{ github.workspace }}/tmp/docker-cache
DOCKER_BUILDKIT: 1
BUILDX_CACHE_PATH: /tmp/.buildx-cache
jobs:
build:
name: build
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Inject slug/short variables
# A GitHub Action to expose the slug values of some GitHub ENV variables
# https://github.com/rlespinasse/github-slug-action
uses: rlespinasse/[email protected]
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: ${{ env.BUILDX_CACHE_PATH }}
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- uses: docker/build-push-action@v3
# GitHub Action to build and push Docker images with Buildx
# https://github.com/docker/build-push-action
name: Build image
with:
push: false
target: builder
tags: ${{ github.repository }}:${{ env.GITHUB_SHA_SHORT }}
cache-from: type=local,src=${{ env.BUILDX_CACHE_PATH }}
cache-to: type=local,dest=${{ env.BUILDX_CACHE_PATH }}
check:
name: check
runs-on: ubuntu-20.04
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Inject slug/short variables
# A GitHub Action to expose the slug values of some GitHub ENV variables
# https://github.com/rlespinasse/github-slug-action
uses: rlespinasse/[email protected]
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Get cached Docker layers
uses: actions/cache@v3
with:
path: ${{ env.BUILDX_CACHE_PATH }}
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- uses: docker/build-push-action@v3
# GitHub Action to build and push Docker images with Buildx
# https://github.com/docker/build-push-action
name: Build image
with:
push: false
target: linter
tags: ${{ github.repository }}:${{ env.GITHUB_SHA_SHORT }}
cache-from: type=local,src=${{ env.BUILDX_CACHE_PATH }}
load: true
- uses: addnab/docker-run-action@v2
# Run an image built by a previous step.
# https://github.com/addnab/docker-run-action
# https://github.com/marketplace/actions/docker-run-action
name: Check format
with:
image: ${{ github.repository }}:${{ env.GITHUB_SHA_SHORT }}
run: mage fmt:check
- uses: addnab/docker-run-action@v2
# Run an image built by a previous step.
# https://github.com/addnab/docker-run-action
# https://github.com/marketplace/actions/docker-run-action
name: Run linter
with:
image: ${{ github.repository }}:${{ env.GITHUB_SHA_SHORT }}
run: mage fmt:lint
test:
name: test
needs: [build, check]
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Inject slug/short variables
# A GitHub Action to expose the slug values of some GitHub ENV variables
# https://github.com/rlespinasse/github-slug-action
uses: rlespinasse/[email protected]
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Get cached Docker layers
uses: actions/cache@v3
with:
path: ${{ env.BUILDX_CACHE_PATH }}
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- uses: docker/build-push-action@v3
# GitHub Action to build and push Docker images with Buildx
# https://github.com/docker/build-push-action
name: Build image
with:
push: false
target: builder
load: true
tags: ${{ github.repository }}:${{ env.GITHUB_SHA_SHORT }}
cache-from: type=local,src=${{ env.BUILDX_CACHE_PATH }}
- uses: addnab/docker-run-action@v2
# Run an image built by a previous step.
# https://github.com/addnab/docker-run-action
# https://github.com/marketplace/actions/docker-run-action
name: Run tests
with:
image: ${{ github.repository }}:${{ env.GITHUB_SHA_SHORT }}
run: mage test:run