Skip to content

Commit

Permalink
Upgrade CI test instance specs (#3598)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalrymple committed Jun 3, 2024
1 parent 0828a44 commit 272de6c
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 28 deletions.
39 changes: 14 additions & 25 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,38 +158,25 @@ test:live:setup:
GITLAB_VERSION: 16.11.3-ce.0
GITLAB_ROOT_PASSWORD: gitbeaker
before_script:
- apk add jq curl
- apk add jq curl envsubst
- gcloud components install beta -q
script:
- echo $GCLOUD_SERVICE_KEY | base64 -d | gcloud auth activate-service-account --key-file=-
- gcloud --quiet config set project ${GOOGLE_PROJECT_ID} --no-user-output-enabled
- envsubst < scripts/startup.sh > scripts/startup_filled.sh
- |
gcloud compute instances create-with-container $CONTAINER_NAME \
GITLAB_HOST="$(gcloud beta compute instances create $CONTAINER_NAME \
--project gitbeaker \
--machine-type=e2-standard-2 \
--zone=$GCP_ZONE \
--scopes=https://www.googleapis.com/auth/cloud-platform \
--tags http-server,https-server \
--container-image docker.io/gitlab/gitlab-ce:$GITLAB_VERSION \
--container-command '/bin/sh' \
--container-arg="-c" \
--container-arg="printf '#!/usr/bin/env ruby \nu = User.first \nu.admin = true \nu.save! \nt = PersonalAccessToken.new({ user: u, name: \"gitbeaker\", scopes: [\"api\", \"read_user\"]}) \nt.expires_at = 365.days.from_now \nt.set_token(ENV[\"PERSONAL_ACCESS_TOKEN\"]) \nt.save! \nputs t.token\n' > /opt/gitlab/embedded/service/gitlab-rails/db/fixtures/production/40_access_token.rb && /assets/wrapper" \
--container-env ^~^GITLAB_ROOT_PASSWORD=${GITLAB_ROOT_PASSWORD}~PERSONAL_ACCESS_TOKEN=${GITLAB_PERSONAL_ACCESS_TOKEN}~GITLAB_OMNIBUS_CONFIG="gitlab_rails['monitoring_whitelist'] = ['0.0.0.0/0', '172.17.0.1'];" \
--no-user-output-enabled
- gcloud compute instances stop $CONTAINER_NAME --zone=$GCP_ZONE --no-user-output-enabled
- |
gcloud beta compute instances set-scheduling $CONTAINER_NAME \
--zone=$GCP_ZONE \
--max-run-duration=720s \
--instance-termination-action=DELETE \
--no-user-output-enabled
- |
GITLAB_HOST="$(gcloud compute instances start $CONTAINER_NAME \
--format='get(networkInterfaces[0].accessConfigs[0].natIP)' \
--machine-type=e2-highmem-2 \
--boot-disk-size=25GB \
--zone=$GCP_ZONE \
--tags http-server \
--metadata-from-file startup-script=scripts/startup_filled.sh \
--image-family=debian-12 \
--image-project=debian-cloud \
--format='get(networkInterfaces[0].accessConfigs[0].natIP)'
2>/dev/null \
)"
)"
- GITLAB_URL="http://${GITLAB_HOST}"
- echo "GITLAB_URL=${GITLAB_URL}" >> intergration.env
- echo "GITLAB_PERSONAL_ACCESS_TOKEN=${GITLAB_PERSONAL_ACCESS_TOKEN}" >> intergration.env
Expand Down Expand Up @@ -344,13 +331,15 @@ test:integration:core:
test:e2e:rest:
extends: .test:e2e:base
image: mcr.microsoft.com/playwright:v1.41.1-focal
allow_failure: true
before_script:
# reinstall swc due to missing binding for ubuntu image
- yarn add @swc/core
script: yarn test:e2e --projects=@gitbeaker/rest

test:e2e:cli:
extends: .test:e2e:base
allow_failure: true
script: yarn test:e2e --projects=@gitbeaker/cli

# Teardown
Expand Down Expand Up @@ -381,8 +370,8 @@ test:live:teardown:
stage: teardown
image: gcr.io/google.com/cloudsdktool/cloud-sdk:alpine
needs:
- test:e2e:cli
- test:e2e:rest
- test:e2e:cli
only:
refs:
- /^pr-[0-9]+$/
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"dist"
],
"scripts": {
"build": "tsup src/index.ts --format esm --treeshake --target node18",
"build": "tsup src/index.ts --format esm --treeshake --target esnext",
"test:unit": "jest --maxWorkers=50% test/unit",
"test:e2e": "jest --maxWorkers=50% test/e2e",
"lint": "eslint '**/{src,test,scripts}/**/*.ts'",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const hintStyle = Chalk.hex('#6a5f88');
const cli = Sywac.version('-v, --version')
.help('-h, --help')
.showHelpByDefault()
.epilogue('Copyright 2023')
.epilogue(`Copyright ${new Date().getFullYear()}`)
.style({
usagePrefix: usageStyle,
group: groupStyle,
Expand Down
1 change: 1 addition & 0 deletions packages/rest/test/e2e/browser/General.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ describe('Browser Import', () => {
'IssueStateEvents',
'IssueWeightEvents',
'JobArtifacts',
'JobTokenScopes',
'Jobs',
'MergeRequestApprovals',
'MergeRequestAwardEmojis',
Expand Down
2 changes: 1 addition & 1 deletion scripts/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
entrypoint:
- '/bin/sh'
- '-c'
- "printf '#!/usr/bin/env ruby \nu = User.first \nu.admin = true \nu.save! \nt = PersonalAccessToken.new({ user: u, name: \"gitbeaker\", scopes: [\"api\", \"read_user\"]}) \nt.expires_at = 365.days.from_now \nt.set_token(ENV[\"PERSONAL_ACCESS_TOKEN\"]) \nt.save! \nputs t.token\n' > /opt/gitlab/embedded/service/gitlab-rails/db/fixtures/production/40_access_token.rb && /assets/wrapper"
- "printf '#!/usr/bin/env ruby \nu = User.first \nu.admin = true \nu.save! \nt = PersonalAccessToken.new({ user: u, name: \"gitbeaker\", scopes: [\"api\", \"read_user\"]}) \nt.expires_at = 365.days.from_now \nt.set_token(ENV[\"PERSONAL_ACCESS_TOKEN\"]) \nt.save!' > /opt/gitlab/embedded/service/gitlab-rails/db/fixtures/production/40_access_token.rb && /assets/wrapper"
ports:
- '8080:80'
- '8443:443'
14 changes: 14 additions & 0 deletions scripts/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
# Install Docker
apt-get update
apt-get install -y docker.io
# Start Docker service
systemctl start docker
systemctl enable docker

# Pull and run Docker container
set +H

docker run -d -p 80:80 -e GITLAB_ROOT_PASSWORD=$GITLAB_ROOT_PASSWORD -e PERSONAL_ACCESS_TOKEN=$GITLAB_PERSONAL_ACCESS_TOKEN -e GITLAB_OMNIBUS_CONFIG="gitlab_rails['monitoring_whitelist'] = ['0.0.0.0/0', '172.17.0.1'];" docker.io/gitlab/gitlab-ce:$GITLAB_VERSION /bin/sh -c "printf '#!/usr/bin/env ruby \nu = User.first \nu.admin = true \nu.save! \nt = PersonalAccessToken.new({ user: u, name: \"gitbeaker\", scopes: [\"api\", \"read_user\"]}) \nt.expires_at = 365.days.from_now \nt.set_token(ENV[\"PERSONAL_ACCESS_TOKEN\"]) \nt.save!' > /opt/gitlab/embedded/service/gitlab-rails/db/fixtures/production/40_access_token.rb && /assets/wrapper"

set -H

0 comments on commit 272de6c

Please sign in to comment.