Skip to content

Commit

Permalink
ci: Add shared workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuVeber committed Nov 9, 2023
1 parent ebd07d9 commit 6ff6ba1
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/assign-to-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Assign issues and PRs to project

on:
issues:
types: [opened, reopened]

pull_request:
types: [opened, reopened]

workflow_call:
inputs:
project-id:
default: 2
description: Issues and PRs will be assigned to that project. Default to 2 (Hedia).
required: false
type: number

secrets:
ASSIGN_TO_PROJECT_TOKEN:
description: Personal Access Token with "repo" and "project" permissions.
required: true

jobs:
project:
runs-on: ubuntu-latest
steps:

- id: addItem
name: Add to project
uses: actions/[email protected]
with:
project-url: https://github.com/orgs/hedia-team/projects/${{inputs.project-id}}
github-token: ${{ secrets.ASSIGN_TO_PROJECT_TOKEN }}

- if: github.event_name == 'pull_request'
name: Set status
uses: hedia-team/[email protected]
with:
project-url: https://github.com/orgs/hedia-team/projects/${{inputs.project-id}}
github-token: ${{ secrets.ASSIGN_TO_PROJECT_TOKEN }}
item-id: ${{ steps.addItem.outputs.itemId }}
field-keys: Status
field-values: In Progress
77 changes: 77 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Run Build, Tests & SonarCloud Scan

on:
workflow_call:
inputs:
database:
description: Database used in this workflow. Default to none.
required: false
type: string

secrets:
READONLY_NPM_TOKEN:
description: Needed to install private @hedia npm packages
required: true
SONAR_TOKEN:
description: Needed to run SonarCloud Scan
required: true

jobs:
build-test:
runs-on: ubuntu-latest

services:
postgres:
image: ${{ inputs.database && 'postgres' || '' }}
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: ${{ inputs.database }}
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of SonarCloud analysis

- name: Setup Node.js Environment
uses: actions/setup-node@v3
with:
node-version-file: "package.json"
always-auth: true
registry-url: https://registry.npmjs.org
scope: "@hedia"

- name: "Install Dependencies"
run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.READONLY_NPM_TOKEN }}

- name: "Build Repository"
run: "npm run build --if-present"

- name: "Run Tests"
run: "npm run test"

- name: SonarCloud Init
env:
GITHUB_PROJECT: ${{ github.repository }}
run: echo "GITHUB_PROJECT=${GITHUB_PROJECT/\//_}" >> $GITHUB_ENV

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ github.token }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.projectKey=${{ env.GITHUB_PROJECT }}
-Dsonar.organization=${{ github.repository_owner }}
-Dsonar.coverageReportPaths=coverage.xml

0 comments on commit 6ff6ba1

Please sign in to comment.