-
Notifications
You must be signed in to change notification settings - Fork 240
172 lines (166 loc) · 5.5 KB
/
build.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
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
172
name: Build
on:
merge_group:
pull_request:
push:
branches:
- main
- release/**
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v23
with:
nix_path: nixpkgs=channel:nixos-22.11
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- id: changed-files
uses: tj-actions/changed-files@v35
with:
files: |
**/*.go
*.mod
*.sum
- uses: cachix/cachix-action@v12
if: steps.changed-files.outputs.any_changed == 'true'
with:
name: cronos
# github don't pass secrets for pull request from fork repos,
# in that case the push is disabled naturally.
signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
- name: Run build
run: ./scripts/release.sh
if: steps.changed-files.outputs.any_changed == 'true'
- uses: actions/upload-artifact@v3
with:
name: "cronosd-tarball-${{ matrix.os }}"
path: "*.tar.gz"
if-no-files-found: ignore
unittest:
runs-on: ubuntu-latest
timeout-minutes: 40
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v23
with:
nix_path: nixpkgs=channel:nixos-22.11
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-go@v3
with:
go-version: '^1.20.0'
- id: changed-files
uses: tj-actions/changed-files@v35
with:
files: |
**/*.go
*.mod
*.sum
- name: test & coverage report creation
run: |
make test
# run versiondb tests
cd ./versiondb
nix-shell -I nixpkgs=../nix -p rocksdb go_1_20 --run "go test -v -mod=readonly ./... -tags rocksdb,grocksdb_clean_link -coverprofile=coverage.txt"
if: steps.changed-files.outputs.any_changed == 'true'
- name: filter out proto files
run: |
excludelist+=" $(find ./ -type f -name '*.pb.go')"
for filename in ${excludelist}; do
filename=$(echo $filename | sed 's/^./github.com\/crypto-org-chain\/cronos/g')
echo "Excluding ${filename} from coverage report..."
sed -i.bak "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt
done
if: steps.changed-files.outputs.any_changed == 'true'
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.txt,./memiavl/coverage.txt,./versiondb/coverage.txt
fail_ci_if_error: true
if: steps.changed-files.outputs.any_changed == 'true'
gomod2nix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- id: changed-files
uses: tj-actions/changed-files@v35
with:
files: |
go.mod
go.sum
- uses: cachix/install-nix-action@v23
with:
nix_path: nixpkgs=channel:nixos-22.11
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
if: steps.changed-files.outputs.any_changed == 'true'
- name: gomod2nix
run: nix run -f ./nix gomod2nix
if: steps.changed-files.outputs.any_changed == 'true'
- name: check working directory is clean
id: changes
run: |
set +e
(git diff --no-ext-diff --exit-code)
echo "name=changed::$?" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v3
if: steps.changes.outputs.changed == 1
with:
name: gomod2nix.toml
path: ./gomod2nix.toml
- if: steps.changes.outputs.changed == 1
run: echo "Working directory is dirty" && exit 1
contracts:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- id: changed-files
uses: tj-actions/changed-files@v35
with:
files: |
contracts
- uses: cachix/install-nix-action@v23
with:
nix_path: nixpkgs=channel:nixos-22.11
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
if: steps.changed-files.outputs.any_changed == 'true'
- uses: cachix/cachix-action@v12
if: steps.changed-files.outputs.any_changed == 'true'
with:
name: cronos
extraPullNames: dapp
signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
- name: test contracts
if: steps.changed-files.outputs.any_changed == 'true'
run: make test-cronos-contracts
- name: build contracts
if: steps.changed-files.outputs.any_changed == 'true'
run: make gen-cronos-contracts
- name: check working directory is clean
id: changes
run: |
set +e
(git diff --no-ext-diff --exit-code)
echo "name=changed::$?" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v3
if: steps.changes.outputs.changed == 1
with:
name: contracts_out
path: ./contracts/out
if-no-files-found: ignore
- if: steps.changes.outputs.changed == 1
run: echo "Working directory is dirty" && exit 1