-
Notifications
You must be signed in to change notification settings - Fork 5
128 lines (112 loc) · 3.56 KB
/
build-and-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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
---
name: Build and test image
on:
push:
branches:
- master
tags:
- 'v*'
pull_request:
branches:
- master
# cancel outdated jobs for the same reference
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
IMAGE: ${{ github.repository_owner }}/go_tile
TAG: ${{ github.sha }}
jobs:
test:
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install coreutils (macOS)
if: matrix.os == 'macos-latest'
run: brew install coreutils
- name: Run tests
run: make test
- name: Generate certificate
env:
SUBJ: ${{ (matrix.os == 'windows-latest') && '//C=US\ST=None\L=None\O=None\CN=localhost' || '/C=US/ST=None/L=None/O=None/CN=localhost' }}
run: |
openssl req \
-new \
-newkey rsa:4096 \
-days 365 \
-nodes \
-x509 \
-subj "${SUBJ}" \
-keyout localhost.key \
-out localhost.cert
- name: Create metatile directory
run: |
mkdir -p data/ajt/0/0/0/0/0
ln -s ../../../../../../../mock_data/0.meta data/ajt/0/0/0/0/0/0.meta
- name: Build & run server
run: |
make build
./go_tile -tls_cert_path localhost.cert -tls_key_path localhost.key &
- name: Fetch & check tile from server
env:
HTTP_URL: http://localhost:8080/tile/0/0/0.png
HTTPS_URL: https://localhost:8443/tile/0/0/0.png
SHA256SUM: d038526e9db340fca762fe2f7e04a368583d9150a7d59ed8d27e40e4e3e00719
run: |
curl --silent ${HTTP_URL} > tile_http.png
curl --insecure --silent ${HTTPS_URL} > tile_https.png
echo "${SHA256SUM} tile_http.png" | sha256sum --check --status && \
echo "HTTP SHA256SUM Matching!"
echo "${SHA256SUM} tile_https.png" | sha256sum --check --status && \
echo "HTTPS SHA256SUM Matching!"
deploy:
runs-on: ubuntu-latest
needs:
- test
if: ${{ github.event_name != 'pull_request' }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ env.IMAGE }}
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
pull: true
push: true
context: .
file: docker/Dockerfile.go_tile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ github.workflow }}
cache-to: type=gha,scope=${{ github.workflow }},mode=max