Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
31 changes: 17 additions & 14 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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: |-
{
Expand Down Expand Up @@ -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: |-
{
Expand Down Expand Up @@ -153,15 +155,15 @@ 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: |-
sed -i "s/run-full-yaml/${{ env.SERVICE_NAME }}/" ./tests/fixtures/service.yaml

- 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'

Expand Down Expand Up @@ -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
Expand All @@ -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'

Expand Down Expand Up @@ -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: |-
{
Expand Down Expand Up @@ -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: |-
{
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 7 additions & 7 deletions tests/fixtures/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading