-
Notifications
You must be signed in to change notification settings - Fork 1.2k
191 lines (182 loc) · 7.13 KB
/
workspace-integration-tests.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
183
184
185
186
187
188
189
190
191
name: "Workspace integration tests"
on:
workflow_dispatch:
inputs:
name:
required: false
type: string
description: "The name of the preview environment, or leave empty to use a default name"
version:
required: false
type: string
description: "The version of Gitpod to install (leave empty to target the latest successful build on main)"
skip_deploy:
required: false
type: boolean
description: "Skip deploy preview environment (debug only)"
skip_delete:
required: false
type: boolean
description: "Skip delete preview environment (debug only)"
workflow_call:
inputs:
name:
required: false
type: string
description: "The name of the preview environment, or leave empty to use a default name"
version:
required: false
type: string
description: "The version of Gitpod to install (leave empty to target the latest successful build on main)"
schedule:
- cron: "0 3,12 * * *"
jobs:
create-runner:
uses: gitpod-io/gce-github-runner/.github/workflows/create-vm.yml@main
secrets:
runner_token: ${{ secrets.SELF_HOSTED_GITHUB_RUNNER_TOKEN }}
gcp_credentials: ${{ secrets.SELF_HOSTED_GITHUB_RUNNER_GCP_CREDENTIALS }}
with:
task: workspace-integration-tests
configuration:
name: Configuration
runs-on: ${{ needs.create-runner.outputs.label }}
needs: [create-runner]
container:
image: eu.gcr.io/gitpod-core-dev/dev/dev-environment:aledbf-update-image-gha.17642
outputs:
name: ${{ steps.configuration.outputs.name }}
version: ${{ steps.configuration.outputs.version }}
steps:
- id: auth
uses: google-github-actions/auth@v1
continue-on-error: true
with:
token_format: access_token
credentials_json: "${{ secrets.GCP_CREDENTIALS }}"
# do this step as early as possible, so that Slack Notify failure has the secret
- name: Get Secrets from GCP
id: "secrets"
uses: "google-github-actions/get-secretmanager-secrets@v1"
with:
secrets: |-
WORKSPACE_SLACK_WEBHOOK:gitpod-core-dev/workspace-slack-webhook
- name: "Set outputs"
id: configuration
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [[ '${{ inputs.name }}' != '' ]]; then
{
echo "name=${{ inputs.name }}"
} >> $GITHUB_OUTPUT
else
{
echo "name=workspace-integration-test-${{ github.run_id }}-${{ github.run_attempt }}"
} >> $GITHUB_OUTPUT
fi
if [[ '${{ inputs.version }}' != '' ]]; then
{
echo "version=${{ inputs.version }}"
} >> $GITHUB_OUTPUT
else
# Find the most recent successful build on main. Look back up to 10 builds.
RUNID=$(gh run list --repo gitpod-io/gitpod --branch main --workflow Build --limit 10 --json createdAt,conclusion,databaseId --jq 'map(select(.conclusion == "success")) | sort_by(.createdAt) | .[-1] | .databaseId')
if [ "$RUNID" == "" ]; then
echo no successful build found on main branch in the last 10 commits, see https://github.com/gitpod-io/gitpod/actions/workflows/build.yml for details | tee -a $GITHUB_STEP_SUMMARY
exit 1
fi
{
echo "version=$(gh run view "$RUNID" --log -R gitpod-io/gitpod | grep 'main-gha.[0-9]*' -o | head -n 1)"
} >> $GITHUB_OUTPUT
fi
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
if: failure()
env:
SLACK_WEBHOOK: ${{ steps.secrets.outputs.WORKSPACE_SLACK_WEBHOOK }}
SLACK_ICON_EMOJI: ":test_tube:"
SLACK_USERNAME: "Integration Tests: workspace"
SLACK_COLOR: ${{ job.status }}
SLACK_MESSAGE: "Workspace Integration Tests failed during configuration, is main build green?"
SLACK_FOOTER: "<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|Workflow logs>"
infrastructure:
needs: [configuration, create-runner]
runs-on: ${{ needs.create-runner.outputs.label }}
concurrency:
group: ${{ needs.configuration.outputs.name }}-infrastructure
steps:
- uses: actions/checkout@v4
- name: Create preview environment infrastructure
id: create
uses: ./.github/actions/preview-create
with:
name: ${{ needs.configuration.outputs.name }}
sa_key: ${{ secrets.GCP_CREDENTIALS }}
infrastructure_provider: gce
large_vm: true
- name: Deploy Gitpod to the preview environment
if: inputs.skip_deploy != 'true'
id: deploy-gitpod
uses: ./.github/actions/deploy-gitpod
with:
name: ${{ needs.configuration.outputs.name }}
sa_key: ${{ secrets.GCP_CREDENTIALS }}
version: ${{ needs.configuration.outputs.version}}
check:
name: Check for regressions
needs: [configuration, infrastructure, create-runner]
runs-on: ${{ needs.create-runner.outputs.label }}
container:
image: eu.gcr.io/gitpod-core-dev/dev/dev-environment:aledbf-update-image-gha.17642
steps:
- uses: actions/checkout@v4
- id: auth
uses: google-github-actions/auth@v1
with:
token_format: access_token
credentials_json: "${{ secrets.GCP_CREDENTIALS }}"
- name: Get Secrets from GCP
id: "secrets"
uses: "google-github-actions/get-secretmanager-secrets@v1"
with:
secrets: |-
WORKSPACE_SLACK_WEBHOOK:gitpod-core-dev/workspace-slack-webhook
- name: Integration Test
id: integration-test
uses: ./.github/actions/integration-tests
with:
preview_name: ${{ needs.configuration.outputs.name }}
test_suite: workspace
notify_slack_webhook: ${{ steps.secrets.outputs.WORKSPACE_SLACK_WEBHOOK }}
sa_key: ${{ secrets.GCP_CREDENTIALS }}
github_token: ${{ secrets.GITHUB_TOKEN }}
delete:
name: Delete preview environment
needs: [configuration, infrastructure, check, create-runner]
if: inputs.skip_delete != 'true' && always()
runs-on: ${{ needs.create-runner.outputs.label }}
container:
image: eu.gcr.io/gitpod-core-dev/dev/dev-environment:aledbf-update-image-gha.17642
steps:
- uses: actions/checkout@v4
- name: Delete preview environment
uses: ./.github/actions/delete-preview
with:
name: ${{ needs.configuration.outputs.name }}
sa_key: ${{ secrets.GCP_CREDENTIALS }}
delete-runner:
if: always()
needs:
- create-runner
- configuration
- infrastructure
- check
- delete
uses: gitpod-io/gce-github-runner/.github/workflows/delete-vm.yml@main
secrets:
gcp_credentials: ${{ secrets.SELF_HOSTED_GITHUB_RUNNER_GCP_CREDENTIALS }}
with:
runner-label: ${{ needs.create-runner.outputs.label }}
machine-zone: ${{ needs.create-runner.outputs.machine-zone }}