Skip to content

Commit b5e9449

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

File tree

1 file changed

+167
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)