-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcontinuous-integration-workflow.yml
More file actions
171 lines (165 loc) · 5.95 KB
/
continuous-integration-workflow.yml
File metadata and controls
171 lines (165 loc) · 5.95 KB
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
name: CI
on: [push]
env:
CACHE_VERSION: 9c3bfa173ea0aca1f9939f8896feb4a4
jobs:
core:
strategy:
fail-fast: false
matrix:
cmd: ['go_core_tests']
name: Core Tests
runs-on: ubuntu-latest
container:
image: smartcontract/builder:1.0.37
credentials:
username: ${{ secrets.DOCKER_READONLY_USERNAME }}
password: ${{ secrets.DOCKER_READONLY_PASSWORD }}
env:
DATABASE_URL: postgres://plugin@postgres:5432/plugin_test?sslmode=disable
LOG_LEVEL: debug
services:
postgres:
image: postgres
credentials:
username: ${{ secrets.DOCKER_READONLY_USERNAME }}
password: ${{ secrets.DOCKER_READONLY_PASSWORD }}
env:
POSTGRES_USER: postgres
POSTGRES_HOST_AUTH_METHOD: trust
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: Set up Postgres user
uses: docker://postgres
with:
args: psql -v ON_ERROR_STOP=1 --username postgres -h postgres -c "CREATE USER plugin NOSUPERUSER CREATEDB;"
- name: Install Postgres for CLI tools
run: wget --quiet -O - https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - && wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - && echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" |sudo tee /etc/apt/sources.list.d/pgdg.list && sudo apt update && sudo apt install -y postgresql-client-13
- name: Cache Yarn dependencies
uses: actions/cache@v2
with:
path: /usr/local/share/.cache/yarn
key: yarn-${{ env.CACHE_VERSION }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn-${{ env.CACHE_VERSION }}
- name: Install Yarn dependencies
run: make yarndep
- name: Cache Go vendor packages
uses: actions/cache@v2
with:
path: /go/pkg/mod
key: go-mod-${{ env.CACHE_VERSION }}-${{ hashFiles('go.sum') }}
restore-keys: |
go-mod-${{ env.CACHE_VERSION }}
- name: Download Go vendor packages
run: go mod download
- name: Compile all contracts
run: ./contracts/scripts/native_solc_compile_all
- name: Verify local solc binaries
run: ./tools/ci/check_solc_hashes
- name: Setup DB
run: go run ./core local db preparetest
- name: Run tests
run: ./tools/bin/${{ matrix.cmd }}
- name: Store logs artifacts on failure
if: failure()
uses: actions/upload-artifact@v1
with:
name: ${{ matrix.cmd }}_logs
path: ./output.txt
- name: Print postgres logs
if: always()
uses: docker://docker:latest
with:
args: logs ${{ job.services.postgres.id }}
integration:
name: Integration tests running ./compose ${{ matrix.test }} against ${{ matrix.node }}
runs-on: [self-hosted, sdlc-ghr-prod]
timeout-minutes: 17
strategy:
matrix:
test: ['test', 'test:ts']
node: ['geth', 'parity']
env:
GETH_MODE: ${{ matrix.node == 'geth' }}
CI: true
PLUGIN_DB_NAME: postgres
EXPLORER_DOCKER_TAG: ${{ fromJSON('["latest", "develop"]')[github.ref == 'refs/heads/master'] }} # https://github.community/t/do-expressions-support-ternary-operators-to-change-their-returned-value/18114/4
steps:
- name: Checkout the repo
uses: actions/checkout@v2
# Login to dockerhub so that we don't get rate limited
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_READONLY_USERNAME }}
password: ${{ secrets.DOCKER_READONLY_PASSWORD }}
- name: Run tests
run: timeout --foreground 1200s ./compose ${{ matrix.test }}
working-directory: ./tools/docker
- name: Cleanup
if: always()
run: ./compose ${{ matrix.test }}:down
working-directory: ./tools/docker
- name: Store logs artifacts on failure
if: failure()
uses: actions/upload-artifact@v1
with:
name: logs
path: ./tools/docker/logs
prepublish_npm:
name: Prepublish NPM
runs-on: ubuntu-latest
container:
image: smartcontract/builder:1.0.37
credentials:
username: ${{ secrets.DOCKER_READONLY_USERNAME }}
password: ${{ secrets.DOCKER_READONLY_PASSWORD }}
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: Yarn cache
uses: actions/cache@v2
env:
cache-name: yarn-cache
with:
path: |
~/.npm
~/.cache
**/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- run: yarn install --frozen-lockfile
- run: ./tools/bin/restore-solc-cache
- name: Run prepublish NPM test
run: ./tools/ci/prepublish_npm_test
build-plugin:
name: Build plugin image
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# Login to dockerhub so that we don't get rate limited
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_READONLY_USERNAME }}
password: ${{ secrets.DOCKER_READONLY_PASSWORD }}
- name: Build image
uses: docker/build-push-action@v2
with:
file: core/plugin.Dockerfile
build_args: COMMIT_SHA=${{ github.sha }},ENVIRONMENT=release
push: false