Skip to content

feat(securitycenter): Add Resource SCC Management API Org ETD custom … #182

feat(securitycenter): Add Resource SCC Management API Org ETD custom …

feat(securitycenter): Add Resource SCC Management API Org ETD custom … #182

Workflow file for this run

# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: CI
on:
push:
branches:
- main
pull_request:
# schedule:
# # https://crontab.guru/#0_12_*_*_0
# - cron: 0 12 * * 0 # At 12:00 on Sunday
env:
GO_VERSION: ^1.22.0
jobs:
affected:
name: Finding affected tests
runs-on: ubuntu-latest
timeout-minutes: 2
outputs:
nodejs-paths: ${{ steps.nodejs.outputs.paths }}
nodejs-setups: ${{ steps.nodejs.outputs.setups }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- run: go build -o ${{ github.workspace }}/tools ./cmd/...
working-directory: .github/cloud-samples-tools
- name: Get diffs
run: git --no-pager diff --name-only HEAD origin/main | tee diffs.txt
- name: Find Node.js affected packages
id: nodejs
run: |
echo "paths=$(./tools affected .github/config/nodejs-prod.jsonc diffs.txt paths.txt)" >> $GITHUB_OUTPUT
cat paths.txt
echo "setups=$(./tools setup-files .github/config/nodejs-prod.jsonc paths.txt)" >> $GITHUB_OUTPUT
nodejs-lint:
name: Node.js lint
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: make lint
- run: ./.github/workflows/utils/region-tags-tests.sh
nodejs-test:
name: Node.js test
needs: affected
runs-on: ubuntu-latest
timeout-minutes: 120 # 2 hours hard limit
permissions:
id-token: write # needed for google-github-actions/auth
strategy:
fail-fast: false
matrix:
path: ${{ fromJson(github.event_name == 'pull_request' && needs.affected.outputs.nodejs-paths || '[]') }}
env:
CI_SETUP: ${{ toJson(fromJson(needs.affected.outputs.nodejs-setups)[matrix.path])}}
steps:
- name: CI Setup
run: echo "${{ env.CI_SETUP }}"
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-node@v4
with:
node-version: ${{ fromJson(env.CI_SETUP).node-version }}
- uses: google-github-actions/auth@v2
with:
project_id: ${{ fromJson(env.CI_SETUP).project-id }}
workload_identity_provider: ${{ fromJson(env.CI_SETUP).workload-identity-provider }}
service_account: ${{ fromJson(env.CI_SETUP).service-account }}
access_token_lifetime: ${{ fromJson(env.CI_SETUP).access-token-lifetime }}
- name: Export environment variables
uses: actions/github-script@v7
id: vars
with:
script: |
const setup = JSON.parse(process.env.CI_SETUP)
const env = {
'GOOGLE_SAMPLES_PROJECT': setup['project-id'],
...setup.env
}
for (const key in env) {
console.log(`${key}: ${env[key]}`)
core.exportVariable(key, env[key])
}
return {
"env": env,
"secrets": Object.keys(setup.secrets)
.map(key => `${key}:${setup.secrets[key]}`)
.join('\n'),
}
- uses: google-github-actions/get-secretmanager-secrets@v2
if: ${{ fromJson(steps.vars.outputs.result).secrets }}
with:
secrets: ${{ fromJson(steps.vars.outputs.result).secrets }}
export_to_environment: true
- name: 🛠️ Test ${{ matrix.path }}
run: |
timeout ${{ fromJson(env.CI_SETUP).timeout-minutes }}m \
make test dir=${{ matrix.path }}
# - name: Upload test results for FlakyBot workflow
# if: github.event.action == 'schedule' && always() # always() submits logs even if tests fail
# uses: actions/upload-artifact@v4
# with:
# name: test-results
# path: ${{ matrix.package }}/${{ env.MOCHA_REPORTER_OUTPUT }}
# retention-days: 1