From 272de6c4dbfa08697d4d99f6bc375bc0b63787ba Mon Sep 17 00:00:00 2001 From: Justin Dalrymple Date: Sun, 2 Jun 2024 23:41:46 -0400 Subject: [PATCH] Upgrade CI test instance specs (#3598) --- .gitlab-ci.yml | 39 ++++++++--------------- packages/cli/package.json | 2 +- packages/cli/src/cli.ts | 2 +- packages/rest/test/e2e/browser/General.ts | 1 + scripts/docker-compose.yml | 2 +- scripts/startup.sh | 14 ++++++++ 6 files changed, 32 insertions(+), 28 deletions(-) create mode 100644 scripts/startup.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 414bb9d19..df337a4b6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 @@ -344,6 +331,7 @@ 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 @@ -351,6 +339,7 @@ test:e2e:rest: test:e2e:cli: extends: .test:e2e:base + allow_failure: true script: yarn test:e2e --projects=@gitbeaker/cli # Teardown @@ -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]+$/ diff --git a/packages/cli/package.json b/packages/cli/package.json index 4df6adcd8..bdd446c07 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -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'", diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index ba810fa1e..58d2e8a50 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -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, diff --git a/packages/rest/test/e2e/browser/General.ts b/packages/rest/test/e2e/browser/General.ts index bd00341b5..c189e9d8b 100644 --- a/packages/rest/test/e2e/browser/General.ts +++ b/packages/rest/test/e2e/browser/General.ts @@ -88,6 +88,7 @@ describe('Browser Import', () => { 'IssueStateEvents', 'IssueWeightEvents', 'JobArtifacts', + 'JobTokenScopes', 'Jobs', 'MergeRequestApprovals', 'MergeRequestAwardEmojis', diff --git a/scripts/docker-compose.yml b/scripts/docker-compose.yml index 2e1744cf8..78efffe30 100644 --- a/scripts/docker-compose.yml +++ b/scripts/docker-compose.yml @@ -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' diff --git a/scripts/startup.sh b/scripts/startup.sh new file mode 100644 index 000000000..3ee83372b --- /dev/null +++ b/scripts/startup.sh @@ -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 \ No newline at end of file