This repository has been archived by the owner on Oct 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
119 lines (105 loc) · 4.03 KB
/
cicd.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
name: CI/CD
on: push
env:
# rewrite go env GOCACHE to something well known so we can use actions/cache with it
GOCACHE: "/home/runner/go/cache"
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.15
uses: actions/setup-go@v2
with:
go-version: 1.15
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/go/src
/home/runner/go/cache
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Print Go Version
run: go version
- name: Build
run: go build -mod=readonly -v .
test:
name: "Test"
needs: [build]
runs-on: ubuntu-latest
env:
TARGET_ENV: "staging"
TESTCASE: "demo/${{ github.event.repository.name }}-staging"
STORMFORGER_JWT: ${{ secrets.STORMFORGER_JWT }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: StormForger | Install forge CLI
run: |
wget https://app.stormforger.com/download/cli/linux -O forge_linux_amd64.tar.gz
tar -xzf forge_linux_amd64.tar.gz
./forge ping
- name: StormForger | Upload data-sources
run: |
./scripts/data-source.sh "${TARGET_ENV}" # export test-data
./forge datasource push demo *.csv --name-prefix-path="${{ github.event.repository.name }}/${TARGET_ENV}/" --auto-field-names
- name: StormForger | Launch test-run
run: |
./forge test-case launch "${TESTCASE}" --test-case-file="./loadtest/loadtest.mjs" \
--define ENV=\"${TARGET_ENV}\" \
--title="${TITLE}" --notes="${NOTES}" \
--label="git-ref=${{github.ref}}" \
--label="gh-commit=${{github.event.head_commit.url}}" \
--label="gh-workflow=${{github.workflow}}" \
--label="gh-run-url=https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}" \
--label="gh-actor=${{github.actor}}" \
${LAUNCH_ARGS}
env:
LAUNCH_ARGS: "--validate"
NOTES: |
Head Commit Message:
${{github.event.head_commit.message}}
TITLE: "${{github.workflow}}#${{github.run_number}} (${{github.ref}})"
deploy:
name: "Deploy (Production)"
needs: [test]
runs-on: ubuntu-latest
env:
TARGET_ENV: "production"
TESTCASE: "demo/${{ github.event.repository.name }}-production"
STORMFORGER_JWT: ${{ secrets.STORMFORGER_JWT }}
# run the deploy pipeline on master only
if: github.ref == 'refs/heads/master'
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: StormForger | Install forge CLI
run: |
wget https://app.stormforger.com/download/cli/linux -O forge_linux_amd64.tar.gz
tar -xzf forge_linux_amd64.tar.gz
./forge ping
- name: StormForger | Upload data-sources
run: |
./scripts/data-source.sh "${TARGET_ENV}" # export test-data
./forge datasource push demo *.csv --name-prefix-path="${{ github.event.repository.name }}/${TARGET_ENV}/" --auto-field-names
- name: StormForger | Launch test-run
run: |
./forge test-case launch "${TESTCASE}" --test-case-file="./loadtest/loadtest.mjs" \
--define ENV=\"${TARGET_ENV}\" \
--title="${TITLE}" --notes="${NOTES}" \
--label="git-ref=${{github.ref}}" \
--label="gh-commit=${{github.event.head_commit.url}}" \
--label="gh-workflow=${{github.workflow}}" \
--label="gh-run-url=https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}" \
--label="gh-actor=${{github.actor}}" \
${LAUNCH_ARGS}
env:
LAUNCH_ARGS: "--nfr-check-file=./loadtest/loadtest.nfr.yaml"
NOTES: |
Head Commit Message:
${{github.event.head_commit.message}}
TITLE: "${{github.workflow}}#${{github.run_number}} (${{github.ref}})"