forked from Finschia/ostracon
-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (120 loc) · 3.92 KB
/
e2e.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
name: e2e
# Runs the CI end-to-end test network on all pushes to master or release branches
# and every pull request, but only if any Go files have been changed.
on:
pull_request:
push:
branches:
- main
- release/**
env:
TAG: ostracon/e2e-node:local-version # See test/e2e/Makefile:docker
CACHE_DIR: /tmp/ostracon/e2etest
jobs:
e2e-build:
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
CACHE_FILE: ${{ steps.prep.outputs.CACHE_FILE }}
steps:
- uses: actions/setup-go@v3
with:
go-version: '1.18'
- uses: actions/checkout@v3
with:
submodules: true
- uses: technote-space/[email protected]
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- name: Create cache directory
run: |
mkdir -p /tmp/.buildx-cache
mkdir -p ${{ env.CACHE_DIR }}
- name: Prepare
id: prep
run: |
HASH_GHE=${{ github.sha }}
VARIANT=$(TZ=UTC-9 date '+%Y%m')${HASH_GHE:0:7}
NAME_TAR="${VARIANT}.tar"
CACHE_FILE=${{ env.CACHE_DIR }}"/${NAME_TAR}"
echo "CACHE_FILE=${CACHE_FILE}" >> $GITHUB_OUTPUT
if: "env.GIT_DIFF != ''"
- name: Get Docker Image File from cache
id: cache
uses: actions/cache@v3
with:
path: ${{ env.CACHE_DIR }}
key: ${{ steps.prep.outputs.CACHE_FILE }}
if: "env.GIT_DIFF != ''"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
if: "env.GIT_DIFF != '' && steps.cache.outputs.cache-hit != 'true'"
- name: Get cached Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
if: "env.GIT_DIFF != '' && steps.cache.outputs.cache-hit != 'true'"
- name: Build e2e Docker
uses: docker/build-push-action@v4
with:
context: .
file: ./test/e2e/docker/Dockerfile
tags: ${{ env.TAG }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
load: true
if: "env.GIT_DIFF != '' && steps.cache.outputs.cache-hit != 'true'"
- name: Move cached Docker layers
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
if: "env.GIT_DIFF != '' && steps.cache.outputs.cache-hit != 'true'"
- name: Save Docker Image
run: |
docker save -o ${{ steps.prep.outputs.CACHE_FILE }} ${{ env.TAG }}
if: "env.GIT_DIFF != '' && steps.cache.outputs.cache-hit != 'true'"
e2e-test:
needs: e2e-build
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: '1.18'
- uses: actions/checkout@v3
- uses: technote-space/[email protected]
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- name: Get Docker Image File from cache
id: cache
uses: actions/cache@v3
with:
path: ${{ env.CACHE_DIR }}
key: ${{ needs.e2e-build.outputs.CACHE_FILE }}
if: "env.GIT_DIFF != ''"
- name: Load Docker Image on Docker
run: |
docker load -i ${{ needs.e2e-build.outputs.CACHE_FILE }}
if: "env.GIT_DIFF != ''"
- name: Build libsodium
run: make libsodium
- name: Build e2e runner
working-directory: test/e2e
run: make runner
if: "env.GIT_DIFF != ''"
- name: Run CI testnet
working-directory: test/e2e
run: ./build/runner -f networks/ci.toml
if: "env.GIT_DIFF != ''"
- name: Emit logs on failure
if: ${{ failure() }}
working-directory: test/e2e
run: ./build/runner -f networks/ci.toml logs