Skip to content

Commit 62e306b

Browse files
committed
[tests] move Workspace Tests to Github Actions
1 parent 85cf075 commit 62e306b

File tree

3 files changed

+165
-289
lines changed

3 files changed

+165
-289
lines changed
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
name: "Workspace integration tests"
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
name:
6+
required: true
7+
description: "The name of the preview environment"
8+
version:
9+
required: true
10+
description: "The version of Gitpod to install"
11+
skip_deploy:
12+
required: false
13+
description: "Skip deploy preview environment (debug only)"
14+
skip_delete:
15+
required: false
16+
description: "Skip delete preview environment (debug only)"
17+
schedule:
18+
- cron: "0 3 * * *"
19+
jobs:
20+
configuration:
21+
name: Configuration
22+
runs-on: [self-hosted]
23+
container:
24+
image: eu.gcr.io/gitpod-core-dev/dev/dev-environment:kylos101-kubecdl-home.1
25+
outputs:
26+
name: ${{ steps.configuration.outputs.name }}
27+
version: ${{ steps.configuration.outputs.version }}
28+
steps:
29+
- name: "Set outputs"
30+
id: configuration
31+
shell: bash
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
run: |
35+
if [[ '${{ github.event.inputs.name }}' != '' && '${{ github.event.inputs.name }}' != 'latest' ]]; then
36+
# The workflow was triggered by workflow_dispatch
37+
{
38+
echo "version=${{ github.event.inputs.version }}"
39+
echo "name=${{ github.event.inputs.name }}"
40+
} >> $GITHUB_OUTPUT
41+
else
42+
# others
43+
RUNID=$(gh run list -R gitpod-io/gitpod -b main -w Build --limit 1 --json databaseId --jq .[0].databaseId)
44+
if ! gh run watch "$RUNID" --exit-status -R gitpod-io/gitpod >/dev/null 2>&1; then
45+
echo main branch build is failed, see https://github.com/gitpod-io/gitpod/actions/runs/"$RUNID" for detail | tee -a $GITHUB_STEP_SUMMARY
46+
exit 1
47+
fi
48+
49+
{
50+
echo "version=$(gh run view "$RUNID" --log -R gitpod-io/gitpod | grep 'main-gha.[0-9]*' -o | head -n 1)"
51+
echo "name=workspace-integration-test-${{ github.run_id }}-${{ github.run_attempt }}"
52+
} >> $GITHUB_OUTPUT
53+
fi
54+
- name: Slack Notification
55+
uses: rtCamp/action-slack-notify@v2
56+
if: failure()
57+
env:
58+
SLACK_WEBHOOK: ${{ secrets.WORKSPACE_SLACK_WEBHOOK }}
59+
SLACK_COLOR: ${{ job.status }}
60+
SLACK_MESSAGE: main branch build failed
61+
check:
62+
name: Check for regressions
63+
needs: [configuration]
64+
runs-on: [self-hosted]
65+
container:
66+
image: eu.gcr.io/gitpod-core-dev/dev/dev-environment:kylos101-kubecdl-home.1
67+
steps:
68+
- uses: actions/checkout@v3
69+
- name: Create preview environment infrastructure
70+
uses: ./.github/actions/preview-create
71+
with:
72+
name: ${{ needs.configuration.outputs.name }}
73+
infrastructure_provider: harvester
74+
large_vm: true
75+
sa_key: ${{ secrets.GCP_CREDENTIALS }}
76+
- name: Deploy Gitpod to the preview environment
77+
if: github.event.inputs.skip_deploy != 'true'
78+
id: deploy-gitpod
79+
uses: ./.github/actions/deploy-gitpod
80+
with:
81+
name: ${{ needs.configuration.outputs.name }}
82+
sa_key: ${{ secrets.GCP_CREDENTIALS }}
83+
version: ${{ needs.configuration.outputs.version}}
84+
- name: Integration Test
85+
shell: bash
86+
env:
87+
ROBOQUAT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88+
USERNAME: ${{ secrets.WORKSPACE_INTEGRATION_TEST_USERNAME }}
89+
USER_TOKEN: ${{ secrets.WORKSPACE_INTEGRATION_TEST_USER_TOKEN }}
90+
PREVIEW_ENV_DEV_SA_KEY: ${{ secrets.GCP_CREDENTIALS }}
91+
PREVIEW_NAME: ${{ needs.configuration.outputs.name }}
92+
run: |
93+
set -euo pipefail
94+
95+
export LEEWAY_WORKSPACE_ROOT="$(pwd)"
96+
export HOME="/home/gitpod"
97+
export PREVIEW_ENV_DEV_SA_KEY_PATH="/home/gitpod/.config/gcloud/preview-environment-dev-sa.json"
98+
99+
echo "${PREVIEW_ENV_DEV_SA_KEY}" > "${PREVIEW_ENV_DEV_SA_KEY_PATH}"
100+
gcloud auth activate-service-account --key-file "${PREVIEW_ENV_DEV_SA_KEY_PATH}"
101+
102+
leeway run dev/preview/previewctl:install
103+
104+
echo "Setting up access to core-dev and harvester"
105+
previewctl get-credentials --gcp-service-account "${PREVIEW_ENV_DEV_SA_KEY_PATH}"
106+
107+
previewctl install-context --branch "${PREVIEW_NAME}" --log-level debug --timeout 1m --gcp-service-account "${PREVIEW_ENV_DEV_SA_KEY_PATH}"
108+
109+
# start integration test
110+
args=()
111+
args+=( "-kubeconfig=/home/gitpod/.kube/config" )
112+
args+=( "-namespace=default" )
113+
[[ "$USERNAME" != "" ]] && args+=( "-username=$USERNAME" )
114+
args+=( "-timeout=60m" )
115+
116+
BASE_TESTS_DIR="$GITHUB_WORKSPACE/test/tests"
117+
CONTENT_SERVICE_TESTS="$BASE_TESTS_DIR/components/content-service"
118+
IMAGE_BUILDER_TESTS="$BASE_TESTS_DIR/components/image-builder"
119+
DATABASE_TESTS="$BASE_TESTS_DIR/components/database"
120+
SERVER_TESTS="$BASE_TESTS_DIR/components/server"
121+
WS_DAEMON_TESTS="$BASE_TESTS_DIR/components/ws-daemon"
122+
WS_MANAGER_TESTS="$BASE_TESTS_DIR/components/ws-manager"
123+
WORKSPACE_TESTS="$BASE_TESTS_DIR/components/workspace"
124+
125+
go install github.com/jstemmer/go-junit-report/v2@latest
126+
127+
FAILURE_COUNT=0
128+
129+
WORKSPACE_TEST_LIST=("$CONTENT_SERVICE_TESTS" "$IMAGE_BUILDER_TESTS" "$DATABASE_TESTS" "$SERVER_TESTS" "$WS_DAEMON_TESTS" "$WS_MANAGER_TESTS" "$WORKSPACE_TESTS")
130+
for TEST_PATH in "${WORKSPACE_TEST_LIST[@]}"
131+
do
132+
TEST_NAME=$(basename "${TEST_PATH}")
133+
echo "running integration for ${TEST_NAME}"
134+
135+
cd "${TEST_PATH}"
136+
set +e
137+
go test -v ./... "${args[@]}" 2>&1 | go-junit-report -subtest-mode=exclude-parents -set-exit-code -out "TEST-${TEST_NAME}.xml" -iocopy
138+
RC=${PIPESTATUS[0]}
139+
set -e
140+
141+
if [ "${RC}" -ne "0" ]; then
142+
FAILURE_COUNT=$((FAILURE_COUNT+1))
143+
fi
144+
done
145+
146+
exit $FAILURE_COUNT
147+
- name: Test Summary
148+
id: test_summary
149+
uses: test-summary/action@v2
150+
with:
151+
paths: "test/tests/**/TEST-*.xml"
152+
if: always()
153+
- name: Slack Notification
154+
uses: rtCamp/action-slack-notify@v2
155+
if: success() || failure()
156+
env:
157+
SLACK_WEBHOOK: ${{ secrets.WORKSPACE_SLACK_WEBHOOK }}
158+
SLACK_COLOR: ${{ job.status }}
159+
SLACK_MESSAGE: ${{ steps.test_summary.outputs.passed }}/${{ steps.test_summary.outputs.total }} tests passed
160+
- name: Delete preview environment
161+
if: github.event.inputs.skip_delete != 'true' && (success() || failure())
162+
uses: ./.github/actions/delete-preview
163+
with:
164+
name: ${{ needs.configuration.outputs.name }}
165+
sa_key: ${{ secrets.GCP_CREDENTIALS }}

.werft/workspace-run-integration-tests.sh

Lines changed: 0 additions & 214 deletions
This file was deleted.

0 commit comments

Comments
 (0)