From c63f8a712431752d9d53538fa590a804ca332b92 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Thu, 17 Jul 2025 16:37:26 -0400 Subject: [PATCH] Add linters --- .github/workflows/integration.yml | 19 +++++++++++++------ .github/workflows/unit.yml | 8 +------- action.yml | 8 ++++---- package.json | 4 ++++ tests/fixtures/clouddeploy.yaml.template | 8 +++++--- tests/fixtures/gha-test-app.yaml | 4 ++-- tests/fixtures/skaffold.yaml | 8 ++++---- 7 files changed, 33 insertions(+), 26 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index cdc7ec7..616c2e4 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -24,7 +24,8 @@ env: jobs: test: - if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name && github.actor != 'dependabot[bot]' }} + if: |- + ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name && github.actor != 'dependabot[bot]' }} runs-on: 'ubuntu-latest' steps: @@ -35,13 +36,13 @@ jobs: - id: 'compute-test-uid' name: 'Compute test UID' run: |- - echo "TEST_UID=${GITHUB_JOB}-${GITHUB_SHA::7}-${GITHUB_RUN_NUMBER}" >> ${GITHUB_ENV} + echo "TEST_UID=${GITHUB_JOB}-${GITHUB_SHA::7}-${GITHUB_RUN_NUMBER}" >> "${GITHUB_ENV}" - id: 'set-up-node' name: 'Set up Node' uses: 'actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a' # ratchet:actions/setup-node@v4 with: - node-version: '20.x' + node-version-file: 'package.json' - id: 'build' name: 'Build' @@ -69,7 +70,10 @@ jobs: - id: 'create-pipeline' name: 'Create pipeline' - run: 'gcloud deploy apply --file=tests/fixtures/clouddeploy.yaml --region=${REGION}' + run: |- + gcloud deploy apply \ + --file="tests/fixtures/clouddeploy.yaml" \ + --region="${REGION}" - id: 'create-release' name: 'Create release' @@ -89,9 +93,12 @@ jobs: - id: 'report-release' name: 'Report Cloud Deploy release' + env: + RELEASE_NAME: '${{ steps.create-release.outputs.name }}' + RELEASE_LINK: '${{ steps.create-release.outputs.link }}' run: |- - echo "Created release: ${{ steps.create-release.outputs.name }}" - echo "Release link: ${{ steps.create-release.outputs.link }}" + echo "Created release: ${RELEASE_NAME}" + echo "Release link: ${RELEASE_LINK}" - id: 'run-e2e-tests' name: 'Run Tests' diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index 75839f5..69433c3 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/action.yml b/action.yml index 4e94a5b..26361c5 100644 --- a/action.yml +++ b/action.yml @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -name: Create Cloud Deploy Release -author: Google LLC +name: 'Create Cloud Deploy Release' +author: 'Google LLC' description: |- Use this action to create a release in Cloud Deploy. @@ -112,12 +112,12 @@ inputs: outputs: name: - description: + description: |- The full name of the release in Cloud Deploy, including project and pipeline names, as well as the chosen name of the release itself. link: - description: + description: |- A link to the Cloud Deploy release in the Google Cloud Web Console. branding: diff --git a/package.json b/package.json index 9e3f9af..8ac6d53 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,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/create-cloud-deploy-release.git" diff --git a/tests/fixtures/clouddeploy.yaml.template b/tests/fixtures/clouddeploy.yaml.template index 8f3454b..99cbdd5 100644 --- a/tests/fixtures/clouddeploy.yaml.template +++ b/tests/fixtures/clouddeploy.yaml.template @@ -19,10 +19,12 @@ metadata: description: 'Deployment pipeline for GitHub Action tests' serialPipeline: stages: - - targetId: 'gha-test-target' - profiles: ['gha-test'] + - targetId: 'gha-test-target' + profiles: ['gha-test'] + +# yamllint disable-line rule:document-start --- -apiVersion: deploy.cloud.google.com/v1 +apiVersion: 'deploy.cloud.google.com/v1' kind: 'Target' metadata: name: 'gha-test-target' diff --git a/tests/fixtures/gha-test-app.yaml b/tests/fixtures/gha-test-app.yaml index 105333b..2eb09a2 100644 --- a/tests/fixtures/gha-test-app.yaml +++ b/tests/fixtures/gha-test-app.yaml @@ -20,7 +20,7 @@ spec: template: spec: containers: - - name: 'gha-test-app' - image: 'gha-test-app' + - name: 'gha-test-app' + image: 'gha-test-app' scaling: maxInstanceCount: '1' diff --git a/tests/fixtures/skaffold.yaml b/tests/fixtures/skaffold.yaml index 449c8b8..2742f53 100644 --- a/tests/fixtures/skaffold.yaml +++ b/tests/fixtures/skaffold.yaml @@ -17,9 +17,9 @@ kind: 'Config' metadata: name: 'gha-test' profiles: -- name: 'gha-test' - manifests: - rawYaml: - - 'gha-test-app.yaml' + - name: 'gha-test' + manifests: + rawYaml: + - 'gha-test-app.yaml' deploy: cloudrun: {}