generated from UK-Export-Finance/nestjs-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(github-actions): enable various imperative github actions (#847)
## Introduction ✏️ Ensure various imperative pipelines are available for consistent pipeline actions across all the applications. ## Resolution ✔️ * Added `github.yml` for PR lint check. * Added `prettier:all` check to `lint.yml`. * Added `pr.yml` check for stale PR validation. * Updated `publish.yml` as per latest `Google Release please` release notes. ## Miscellaneous ➕ * Dependencies updates * Moved GHA hardcoded variables to Enterprise scope GH secrets / variable * Refactored GitHooks --------- Co-authored-by: Abhi Markan <[email protected]>
- Loading branch information
1 parent
93a9a91
commit fbfafa9
Showing
13 changed files
with
292 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# This GitHub Actions workflow ensures that any pull request targeting the main or main-* | ||
# branches meets certain criteria before it is merged. The workflow sets up the necessary infrastructure, | ||
# configures the environment, and performs checks on the pull request title, body, labels | ||
# and assignee to ensure that it adheres to predefined standards. If any of these checks fail, | ||
# the workflow will exit with an error, preventing the pull request from proceeding. | ||
|
||
name: GitHub | ||
run-name: 🔬 Pull request inspection on ${{ github.event.number }} | ||
|
||
on: | ||
pull_request: | ||
branches: [main, main-*] | ||
|
||
env: | ||
environment: "qa" | ||
timezone: ${{ vars.TIMEZONE }} | ||
|
||
jobs: | ||
# 1. Setup test infrastructure | ||
setup: | ||
name: Infrastructure setup 🔧 | ||
runs-on: ubuntu-latest | ||
outputs: | ||
environment: ${{ env.environment }} | ||
timezone: ${{ env.timezone }} | ||
steps: | ||
- name: Environment 🧪 | ||
run: echo "Environment set to ${{ env.environment }}" | ||
|
||
- name: Timezone 🌐 | ||
run: echo "Timezone set to ${{ env.timezone }}" | ||
|
||
# 2. Pull request | ||
pullrequest: | ||
name: Pull request ⬇️ | ||
needs: setup | ||
environment: | ||
name: ${{ needs.setup.outputs.environment }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Timezone | ||
uses: szenius/[email protected] | ||
with: | ||
timezoneLinux: ${{ needs.setup.outputs.timezone }} | ||
|
||
- name: Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ vars.NODE_VERSION }} | ||
|
||
- name: Dependencies | ||
working-directory: ./ | ||
run: npm ci --legacy-peer-deps | ||
|
||
- name: Title | ||
run: echo "${{ github.event.pull_request.title }}" | npx commitlint --color --verbose $1 | ||
|
||
- name: Body | ||
if: ${{ github.event.pull_request.body == '' }} | ||
run: exit 1 | ||
|
||
- name: Label | ||
if: ${{ github.event.pull_request.labels == '[]' }} | ||
run: exit 1 | ||
|
||
- name: Assignee | ||
if: ${{ github.event.pull_request.assignee == '[]' }} | ||
run: exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,48 @@ | ||
# MDM-API Git Hub Actions | ||
##################################### | ||
# This GHA is responsible for initiating linting checks | ||
# Workflow Name: Lint | ||
# Trigger: Pull requests to the main branch that modify specific files (listed in paths). | ||
# | ||
# Environment: | ||
# environment: set to dev | ||
# timezone: retrieved from vars.TIMEZONE | ||
# | ||
# Setup Test Infrastructure: | ||
# Name: Infrastructure setup | ||
# Runs on: ubuntu-latest | ||
# Outputs environment and timezone variables for use in subsequent jobs. | ||
# Steps: | ||
# Echoes the environment and timezone for verification. | ||
# | ||
# Lint: | ||
# Name: Scanning | ||
# Depends on: setup | ||
# Runs on: ubuntu-latest | ||
# Steps: | ||
# Sets the timezone using the specified value. | ||
# Checks out the repository code. | ||
# Sets up the specified Node.js version. | ||
# Installs dependencies using npm run ci:all. | ||
# Runs linting using the command npm run lint | ||
# | ||
# Prettier: | ||
# Name: Prettier | ||
# Depends on: setup | ||
# Runs on: ubuntu-latest | ||
# Steps: | ||
# Sets the timezone using the specified value. | ||
# Checks out the repository code. | ||
# Sets up the specified Node.js version. | ||
# Installs dependencies using npm run ci:all. | ||
# Runs prettier using the command npm run prettier. | ||
# | ||
# Key Points: | ||
# The workflow focuses on linting, which checks code for potential errors, style issues, and adherence to best practices. | ||
# It uses a sequential structure, with the linting job depending on the setup job. | ||
# Environment variables are shared between jobs for consistency. | ||
# The workflow leverages actions from the GitHub Marketplace for setting the timezone and installing Node.js. | ||
# | ||
|
||
name: Quality Assurance - Lint | ||
run-name: Executing lint QA on ${{ github.repository }} 🚀 | ||
name: Lint | ||
run-name: 🎨 Lint checking on ${{ github.event.number }} | ||
|
||
on: | ||
pull_request: | ||
|
@@ -14,8 +53,7 @@ on: | |
|
||
env: | ||
environment: "qa" | ||
timezone: "Europe/London" | ||
node: ${{ vars.NODE_VERSION }} | ||
timezone: ${{ vars.TIMEZONE }} | ||
|
||
jobs: | ||
# 1. Setup test infrastructure | ||
|
@@ -40,17 +78,17 @@ jobs: | |
runs-on: ubuntu-latest | ||
steps: | ||
- name: Timezone | ||
uses: szenius/set-timezone@v2.0 | ||
uses: szenius/set-timezone@v1.2 | ||
with: | ||
timezoneLinux: ${{ needs.setup.outputs.timezone }} | ||
|
||
- name: Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Node | ||
uses: actions/setup-node@v4 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ env.node }} | ||
node-version: ${{ vars.NODE_VERSION }} | ||
|
||
- name: Dependencies | ||
working-directory: ./ | ||
|
@@ -59,3 +97,31 @@ jobs: | |
- name: Linting | ||
working-directory: ./ | ||
run: npm run lint | ||
|
||
# 3. Prettier | ||
prettier: | ||
name: Prettier 🎨 | ||
environment: | ||
name: ${{ needs.setup.outputs.environment }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Timezone | ||
uses: szenius/[email protected] | ||
with: | ||
timezoneLinux: ${{ needs.setup.outputs.timezone }} | ||
|
||
- name: Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ vars.NODE_VERSION }} | ||
|
||
- name: Dependencies | ||
working-directory: ./ | ||
run: npm ci --legacy-peer-deps | ||
|
||
- name: Linting | ||
working-directory: ./ | ||
run: npm run prettier |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# This YAML configuration defines a GitHub Actions workflow named "PR" designed to analyse pull requests | ||
# for staleness and take action accordingly. | ||
# | ||
# Identify: Uses the actions/stale@v5 action with parameters to mark pull requests as stale if | ||
# they have been inactive for a certain number of days and close them if they exceed another threshold. | ||
# This workflow helps maintain the health of the pull request queue by identifying and managing stale pull requests automatically. | ||
# | ||
|
||
name: PR | ||
run-name: 🔎 Pull request analysis on ${{ github.event.number }} | ||
|
||
on: | ||
schedule: | ||
- cron: "00 00 * * *" | ||
env: | ||
environment: "qa" | ||
timezone: ${{ vars.TIMEZONE }} | ||
|
||
jobs: | ||
# 1. Setup test infrastructure | ||
setup: | ||
name: Infrastructure setup 🔧 | ||
runs-on: ubuntu-latest | ||
outputs: | ||
environment: ${{ env.environment }} | ||
timezone: ${{ env.timezone }} | ||
steps: | ||
- name: Environment 🧪 | ||
run: echo "Environment set to ${{ env.environment }}" | ||
|
||
- name: Timezone 🌐 | ||
run: echo "Timezone set to ${{ env.timezone }}" | ||
|
||
# 2. Identify stale PRs | ||
stale: | ||
name: Stale 📅 | ||
needs: setup | ||
environment: | ||
name: ${{ needs.setup.outputs.environment }} | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Identify | ||
uses: actions/stale@v9 | ||
with: | ||
days-before-pr-stale: ${{ vars.STALE_PR_DAYS }} | ||
stale-pr-message: "Pull request marked as stale due to inactivity." | ||
stale-pr-label: "Stale" | ||
days-before-pr-close: ${{ vars.CLOSE_PR_DAYS }} | ||
close-pr-message: "Pull request has been closed due to inactivity." | ||
close-pr-label: "Closed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx commitlint --edit $1 | ||
npx lint-staged | ||
npx commitlint --color --edit $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,19 @@ | ||
# Root | ||
node_modules/ | ||
dist/ | ||
.cache/ | ||
build/ | ||
public/ | ||
generated_reports/ | ||
coverage/ | ||
package*.json | ||
.cache | ||
|
||
# Sub-directories | ||
**/node_modules/ | ||
**/dist/ | ||
**/build/ | ||
**/public/ | ||
**/generated_reports/ | ||
**/coverage/ | ||
**/node_modules/** | ||
/node_modules | ||
/package-lock.json | ||
**/package*.json | ||
**/.cache |
Oops, something went wrong.