forked from joltify-finance/joltifychain-bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
85 lines (73 loc) · 2.55 KB
/
.gitlab-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
cache:
paths:
- .cache
before_script:
- mkdir -p .cache
- export GOPATH="$CI_PROJECT_DIR/.cache"
- PATH="$GOPATH/bin:$PATH"
stages:
- build
- test
- upload
- release
variables:
# DARWIN_AMD64_BINARY: "bridgeService-darwin-amd64-${CI_COMMIT_TAG}"
LINUX_AMD64_BINARY: "bridgeSerivce-linux-amd64-${CI_COMMIT_TAG}"
build-job: # This job runs in the build stage, which runs first.
stage: build
image: golang:1.18
script:
- make build
- sha256sum bridge_service> checksum.txt
- mkdir release_files
- cp bridge_service release_files/bridge_service
- cp checksum.txt release_files/${LINUX_AMD64_BINARY}-checksum.txt
artifacts:
paths:
- release_files/
unit_tests:
stage: test
image: golang:1.18
coverage: '/total:\s+\(statements\)\s+(\d+.\d+\%)/'
script:
- go install gotest.tools/gotestsum@latest
- gotestsum --junitfile report.xml --format testname -- -coverprofile=coverage.out -timeout 15m ./...
- cat coverage.out |grep -v "erc20.go"|grep -v "oppy_transfer.go" > cover.out
- go tool cover -func=cover.out
artifacts:
when: always
reports:
junit: report.xml
expire_in: 1 week
lint_code:
image: golangci/golangci-lint
stage: test
before_script:
- go install mvdan.cc/gofumpt@latest
script:
- golangci-lint run -v --timeout 3600s -c ./.golangci.yml
upload-job:
stage: upload
image: curlimages/curl:latest
rules:
- if: $CI_COMMIT_TAG
script:
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file release_files/bridge_service "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${LINUX_AMD64_BINARY}/${CI_COMMIT_TAG}/bridge_service"'
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file release_files/${LINUX_AMD64_BINARY}-checksum.txt "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${LINUX_AMD64_BINARY}/${CI_COMMIT_TAG}/${LINUX_AMD64_BINARY}-checksum.txt"'
release-job:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules:
- if: $CI_COMMIT_TAG
script:
- echo 'running release_job'
release:
name: '$CI_COMMIT_TAG'
tag_name: '$CI_COMMIT_TAG'
description: '$CI_COMMIT_TAG'
assets:
links:
- name: '$LINUX_AMD64_BINARY'
url: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${LINUX_AMD64_BINARY}/${CI_COMMIT_TAG}/bridge_service"
- name: '${LINUX_AMD64_BINARY}-checksum.txt'
url: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${LINUX_AMD64_BINARY}/${CI_COMMIT_TAG}/${LINUX_AMD64_BINARY}-checksum.txt"