diff --git a/.github/workflows/cleanup.yml b/.github/workflows/cleanup.yml index bbcd9e4f..374acbcd 100644 --- a/.github/workflows/cleanup.yml +++ b/.github/workflows/cleanup.yml @@ -26,15 +26,17 @@ jobs: version: 'latest' - name: 'Delete services' + env: + PROJECT_ID: '${{ vars.PROJECT_ID }}' run: |- - gcloud config set core/project "${{ vars.PROJECT_ID }}" + gcloud config set core/project "${PROJECT_ID}" gcloud config set run/region "us-central1" # List and delete all services that were deployed 30 minutes ago or # earlier. The date math here is a little weird, but we're looking for # deployments "earlier than" 30 minutes ago, so it's less than since # time increases. - (IFS=$'\n'; for NAME in $(gcloud run services list --format="value(name)" --filter="metadata.creationTimestamp < '-pt30m'"); do + (IFS=$'\n'; for NAME in $(gcloud run services list --format='value(name)' --filter='metadata.creationTimestamp < "-pt30m"'); do echo "Deleting ${NAME}..." - gcloud run services delete ${NAME} --quiet --async + gcloud run services delete "${NAME}" --quiet --async done) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 890577e1..12b8b569 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -38,12 +38,14 @@ jobs: - uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683' # ratchet:actions/checkout@v4 - name: 'Compute service name' + env: + MATRIX_NAME: '${{ matrix.name }}' run: |- - echo "SERVICE_NAME=${GITHUB_JOB}-${{ matrix.name }}-${GITHUB_SHA::7}-${GITHUB_RUN_NUMBER}" >> ${GITHUB_ENV} + echo "SERVICE_NAME=${GITHUB_JOB}-${MATRIX_NAME}-${GITHUB_SHA::7}-${GITHUB_RUN_NUMBER}" >> "${GITHUB_ENV}" - uses: 'actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a' # ratchet:actions/setup-node@v4 with: - node-version: '20.12.x' # https://github.com/nodejs/node/issues/53033 + node-version-file: 'package.json' - run: 'npm ci && npm run build' @@ -75,7 +77,7 @@ jobs: - name: 'Run initial deploy tests' run: 'npm run e2e-tests' env: - PROJECT_ID: ${{ vars.PROJECT_ID }} + PROJECT_ID: '${{ vars.PROJECT_ID }}' SERVICE: '${{ env.SERVICE_NAME }}' ENV: |- { @@ -111,14 +113,14 @@ jobs: ABC=123 DEF=456 env_vars_update_strategy: 'overwrite' - secrets: /api/secrets/my-secret=${{ vars.SECRET_NAME }}:latest + secrets: '/api/secrets/my-secret=${{ vars.SECRET_NAME }}:latest' secrets_update_strategy: 'overwrite' - to_revision: 'LATEST=100' + revision_traffic: 'LATEST=100' - name: 'Run re-deploy tests' run: 'npm run e2e-tests' env: - PROJECT_ID: ${{ vars.PROJECT_ID }} + PROJECT_ID: '${{ vars.PROJECT_ID }}' SERVICE: '${{ env.SERVICE_NAME }}' ENV: |- { @@ -153,7 +155,7 @@ jobs: - name: 'Compute service name' run: |- - echo "SERVICE_NAME=${GITHUB_JOB}-metadata-${GITHUB_SHA::7}-${GITHUB_RUN_NUMBER}" >> ${GITHUB_ENV} + echo "SERVICE_NAME=${GITHUB_JOB}-metadata-${GITHUB_SHA::7}-${GITHUB_RUN_NUMBER}" >> "${GITHUB_ENV}" - name: 'Set service name in metadata YAML' run: |- @@ -161,7 +163,7 @@ jobs: - uses: 'actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a' # ratchet:actions/setup-node@v4 with: - node-version: '20.12.x' # https://github.com/nodejs/node/issues/53033 + node-version-file: 'package.json' - run: 'npm ci && npm run build' @@ -202,7 +204,7 @@ jobs: with: image: 'gcr.io/cloudrun/hello' service: '${{ env.SERVICE_NAME }}' - to_revision: 'LATEST=100' + revision_traffic: 'LATEST=100' - name: 'Run re-deploy tests' run: 'npm run e2e-tests' # Check that config isn't overwritten @@ -229,11 +231,11 @@ jobs: - name: 'Compute job name' run: |- - echo "JOB_NAME=${GITHUB_JOB}-job-${GITHUB_SHA::7}-${GITHUB_RUN_NUMBER}" >> ${GITHUB_ENV} + echo "JOB_NAME=${GITHUB_JOB}-job-${GITHUB_SHA::7}-${GITHUB_RUN_NUMBER}" >> "${GITHUB_ENV}" - uses: 'actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a' # ratchet:actions/setup-node@v4 with: - node-version: '20.12.x' # https://github.com/nodejs/node/issues/53033 + node-version-file: 'package.json' - run: 'npm ci && npm run build' @@ -264,7 +266,7 @@ jobs: - name: 'Run initial deploy tests' run: 'npm run e2e-tests' env: - PROJECT_ID: ${{ vars.PROJECT_ID }} + PROJECT_ID: '${{ vars.PROJECT_ID }}' JOB: '${{ env.JOB_NAME }}' ENV: |- { @@ -294,12 +296,13 @@ jobs: ABC=123 DEF=456 env_vars_update_strategy: 'overwrite' - secrets: /api/secrets/my-secret=${{ vars.SECRET_NAME }}:latest + secrets: |- + /api/secrets/my-secret=${{ vars.SECRET_NAME }}:latest - name: 'Run re-deploy tests' run: 'npm run e2e-tests' env: - PROJECT_ID: ${{ vars.PROJECT_ID }} + PROJECT_ID: '${{ vars.PROJECT_ID }}' JOB: '${{ env.JOB_NAME }}' ENV: |- { diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index 75839f58..69433c39 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -31,16 +31,10 @@ jobs: - uses: 'actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a' # ratchet:actions/setup-node@v4 with: - node-version: '20.x' + node-version-file: 'package.json' - name: 'npm build' run: 'npm ci && npm run build' - - name: 'npm lint' - # There's no need to run the linter for each operating system, since it - # will find the same thing 3x and clog up the PR review. - if: ${{ matrix.os == 'ubuntu-latest' }} - run: 'npm run lint' - - name: 'npm test' run: 'npm run test' diff --git a/package.json b/package.json index 532ed87b..4807c867 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,10 @@ "test": "node --require ts-node/register --test-reporter spec --test tests/unit/main.test.ts tests/unit/output-parser.test.ts", "e2e-tests": "node --require ts-node/register --test-reporter spec --test tests/e2e.test.ts" }, + "engines": { + "node": "20.x", + "npm": "10.x" + }, "repository": { "type": "git", "url": "https://github.com/google-github-actions/deploy-cloudrun.git" diff --git a/tests/fixtures/service.yaml b/tests/fixtures/service.yaml index 3ef34c34..2f6aaeac 100644 --- a/tests/fixtures/service.yaml +++ b/tests/fixtures/service.yaml @@ -12,11 +12,11 @@ spec: spec: containerConcurrency: 20 containers: - - image: 'gcr.io/cloudrun/hello' - ports: - - containerPort: 8080 - resources: - limits: - cpu: '2' - memory: '1Gi' + - image: 'gcr.io/cloudrun/hello' + ports: + - containerPort: 8080 + resources: + limits: + cpu: '2' + memory: '1Gi' timeoutSeconds: 300