From d302ac52033855338c2cb28fb22de065935b180c Mon Sep 17 00:00:00 2001 From: henrybell Date: Tue, 29 Oct 2024 14:05:58 +0000 Subject: [PATCH] ci: add GitHub Actions config --- .github/dependabot.yaml | 52 +++++++++++++++++++ .github/release-please.yml | 23 +++++++++ .github/workflows/codehealth.yaml | 66 ++++++++++++++++++++++++ .github/workflows/codeql.yaml | 84 +++++++++++++++++++++++++++++++ .github/workflows/unit_tests.yaml | 45 +++++++++++++++++ 5 files changed, 270 insertions(+) create mode 100644 .github/dependabot.yaml create mode 100644 .github/release-please.yml create mode 100644 .github/workflows/codehealth.yaml create mode 100644 .github/workflows/codeql.yaml create mode 100644 .github/workflows/unit_tests.yaml diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..bdc50df --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,52 @@ +# 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. + +--- +updates: + # Github-actions dependencies + - directory: "/" + package-ecosystem: "github-actions" + schedule: + interval: "weekly" + commit-message: + prefix: "fix" + + # NPM dependencies -- only prompt to update minor versions. + - directory: "/" + package-ecosystem: "npm" + schedule: + interval: "weekly" + ignore: + - dependency-name: "*" + update-types: ["version-update:semver-major"] + commit-message: + prefix: "fix" + + # Docker dependencies + - directory: "/" + package-ecosystem: "docker" + schedule: + interval: "weekly" + commit-message: + prefix: "fix" + + # Terraform dependencies + - directory: "/terraform" + package-ecosystem: "terraform" + schedule: + interval: "weekly" + commit-message: + prefix: "fix" + +version: 2 diff --git a/.github/release-please.yml b/.github/release-please.yml new file mode 100644 index 0000000..5680b94 --- /dev/null +++ b/.github/release-please.yml @@ -0,0 +1,23 @@ +# 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. + +handleGHRelease: true +manifest: true +branches: + - branch: version_1 + handleGHRelease: true + manifest: true + - branch: version_2 + handleGHRelease: true + manifest: true diff --git a/.github/workflows/codehealth.yaml b/.github/workflows/codehealth.yaml new file mode 100644 index 0000000..46e9d82 --- /dev/null +++ b/.github/workflows/codehealth.yaml @@ -0,0 +1,66 @@ +# 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: "Code health checks (npm audit, eslint, tscompiler, ...)" + +on: + push: + pull_request: + +jobs: + analyze: + name: "Analyze" + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + strategy: + fail-fast: false + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + check-latest: true + + - name: Use terraform + uses: hashicorp/setup-terraform@v3 + + - name: Install node modules + run: npm install + + - name: Execute "npm run typecheck" + run: npm run typecheck + + - name: Execute "npm run eslint" + run: npm run eslint + + - name: Execute "npm run check-format" + run: npm run check-format + + - name: Execute "npm run mdlint" + run: npm run mdlint + + - name: Execute "npm audit" + run: npm audit + + - name: Execute "npm run markdown-link-check" + run: npm run markdown-link-check + + - name: terraform validate deployments + run: npm run terraform-validate diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml new file mode 100644 index 0000000..fdc90da --- /dev/null +++ b/.github/workflows/codeql.yaml @@ -0,0 +1,84 @@ +# 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. + +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + pull_request: + schedule: + - cron: "27 22 * * 5" + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: ["javascript"] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v3 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/unit_tests.yaml b/.github/workflows/unit_tests.yaml new file mode 100644 index 0000000..ef4603e --- /dev/null +++ b/.github/workflows/unit_tests.yaml @@ -0,0 +1,45 @@ +# 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: Node.js unit tests + +on: [push, pull_request] + +jobs: + unit-tests: + runs-on: ubuntu-latest + + defaults: + run: + working-directory: src/poller/poller-core + + strategy: + matrix: + node-version: [18.x, 20.x, 22.x] + + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: npm install + run: npm install + + - name: Unit tests + run: npm test + env: + CI: true