-
Notifications
You must be signed in to change notification settings - Fork 45
182 lines (166 loc) · 6.3 KB
/
branch-develop.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
173
174
175
176
177
178
179
180
181
182
name: Develop branch workflow
# available flags:
## skip-e2e-tests: skip running e2e tests
## skip-build : run the test with latest version.
## skip-publish: skip publish
on:
pull_request:
types: [labeled, opened, synchronize, unlabeled, closed]
branches:
- develop
- "release/**"
push:
branches: [develop]
workflow_dispatch:
# For manually trigger
inputs:
e2eBranch:
description: "Name of the e2e target branch"
required: false
default: "main"
parachainDocker:
description: "Name of the parachain docker reference"
required: false
default: "mangatasolutions/mangata-node:latest"
skipBuild:
description: "Skip build phase"
type: boolean
required: true
default: false
permissions:
contents: write
id-token: write
deployments: write
checks: write
# The following concurrency group cancels in-progress jobs or runs on pull_request events only
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
init:
name: Global init
if: github.event.action != 'unlabeled' && github.event.action != 'closed'
runs-on: ubuntu-latest
outputs:
GLOBAL_VERSION: ${{ steps.set_vars.outputs.GLOBAL_VERSION }}
GIT_BRANCH: ${{ steps.set_vars.outputs.GIT_BRANCH }}
GIT_BRANCH_UNFORMATTED: ${{ steps.branch-name.outputs.current_branch }}
steps:
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v6
- name: Set global version
id: set_vars
run: |
echo "GLOBAL_VERSION=${{ github.sha }}" >> $GITHUB_OUTPUT
echo "GIT_BRANCH=${{ steps.branch-name.outputs.current_branch }}" | sed "s@/@-@g" >> $GITHUB_OUTPUT
build-and-test:
if: ${{ github.event.inputs.skipBuild != 'true' }}
needs: [init]
name: Build
uses: ./.github/workflows/reusable-build-and-test.yml
secrets: inherit
with:
version: ${{ needs.init.outputs.GLOBAL_VERSION }}
branch: ${{ needs.init.outputs.GIT_BRANCH }}
deploy-fungible:
name: Deploy fungible environment
needs: [init,build-and-test]
if: |
(github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name == ':rocket: deploy') ||
(github.event_name == 'pull_request' && github.event.action != 'labeled' && contains(github.event.pull_request.labels.*.name, ':rocket: deploy'))
uses: ./.github/workflows/reusable-deploy.yml
secrets: inherit
with:
env: fungible
version: ${{ needs.init.outputs.GLOBAL_VERSION }}
cluster_name: mangata-dev-alpha
run-perf-tests-branch:
runs-on: ubuntu-latest
needs: [deploy-fungible]
if: |
(github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name == ':rocket: deploy' && contains(github.event.pull_request.labels.*.name, 'full-benchmarks')) ||
(github.event_name == 'pull_request' && github.event.action != 'labeled' && contains(github.event.pull_request.labels.*.name, ':rocket: deploy') && contains(github.event.pull_request.labels.*.name, 'full-benchmarks'))
steps:
- run: echo "Running perf tests in branch"
run-perf-tests-dev:
runs-on: ubuntu-latest
needs: [deploy-dev]
steps:
- run: echo "Running perf tests in dev"
performance-tests:
name: performance tests in branch
needs: [run-perf-tests-branch]
uses: ./.github/workflows/reusable-perfomance-tests.yml
secrets: inherit
with:
e2eBranch: ${{ github.event.inputs.e2eBranch }}
performance-tests-dev:
name: performance tests in dev
needs: [run-perf-tests-dev]
uses: ./.github/workflows/reusable-perfomance-tests.yml
secrets: inherit
with:
e2eBranch: ${{ github.event.inputs.e2eBranch }}
targetEnv: "dev"
clean-up-fungible:
name: Delete fungible environment
if: |
(github.event_name == 'pull_request' && github.event.action == 'unlabeled' && github.event.label.name == ':rocket: deploy') ||
(github.event_name == 'pull_request' && github.event.action == 'closed' && contains(github.event.pull_request.labels.*.name, ':rocket: deploy'))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: google-github-actions/auth@v1
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- name: Set up GKE credentials
uses: google-github-actions/get-gke-credentials@v0.8.2
with:
cluster_name: mangata-dev-alpha
location: europe-west1
- name: Delete Kubernetes namespace with resources for fungible environment
run: kubectl delete namespace pr-${{ github.event.number }}
- name: Delete GitHub Deployment environment
if: always()
uses: bobheadxi/deployments@v1.3.0
with:
step: delete-env
token: ${{ secrets.GITHUB_TOKEN }}
env: pr-${{ github.event.number }}
deploy-dev:
needs: [init,build-and-test]
if: github.event_name == 'push' && github.ref_name == 'develop'
name: Deploy `dev` environment
uses: ./.github/workflows/reusable-deploy.yml
secrets: inherit
with:
env: dev
version: ${{ needs.init.outputs.GLOBAL_VERSION }}
cluster_name: mangata-dev-alpha
generate-types:
name: Generate types
needs: [init, build-and-test]
uses: ./.github/workflows/reusable-generate-types.yml
secrets: inherit
with:
branch: ${{ needs.init.outputs.GIT_BRANCH_UNFORMATTED }}
parachainDocker: ${{ github.event.inputs.parachainDocker }}
globalVersion: ${{ needs.init.outputs.GLOBAL_VERSION }}
run-e2e-test:
name: Run e2e tests
needs: [init, build-and-test, generate-types]
uses: ./.github/workflows/reusable-e2e-tests.yml
secrets: inherit
permissions:
contents: write
id-token: write
deployments: write
checks: write
with:
e2eBranch: ${{ github.event.inputs.e2eBranch }}
parachainDocker: ${{ github.event.inputs.parachainDocker }}
skipBuild: ${{ github.event.inputs.skipBuild }}
globalVersion: ${{ needs.init.outputs.GLOBAL_VERSION }}