80 lines
2.3 KiB
YAML
80 lines
2.3 KiB
YAML
name: PR
|
|
|
|
on:
|
|
pull_request:
|
|
|
|
concurrency:
|
|
group: ${{ github.event.number }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
client-code-checks:
|
|
name: Client Code Checks
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
name: Set up Node
|
|
with:
|
|
node-version: '20'
|
|
- name: Clean and Install
|
|
run: cd client && npm ci
|
|
- name: Build
|
|
run: cd client && npm run build
|
|
- name: Lint
|
|
run: cd client && npm run lint
|
|
- name: Unit tests
|
|
run: cd client && npm run test:coverage
|
|
|
|
client-sonarcloud:
|
|
name: Client SonarCloud
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- client-code-checks
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
|
- name: SonarCloud Scan
|
|
uses: SonarSource/sonarcloud-github-action@v3.0.0
|
|
with:
|
|
projectBaseDir: client
|
|
args: >
|
|
-Dsonar.organization=ricardo-campos-org
|
|
-Dsonar.projectKey=ricardo-campos-org_react-typescript-todolist
|
|
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
|
|
-Dsonar.sources=src/
|
|
-Dsonar.test.exclusions=src/__test__/setup.ts
|
|
-Dsonar.tests=src/__test__/
|
|
-Dsonar.verbose=true
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
|
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
|
|
client-docker-build:
|
|
name: Build Docker image
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- client-sonarcloud
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/setup-buildx-action@v3
|
|
name: Set up Docker Buildx
|
|
|
|
- uses: docker/login-action@v3
|
|
name: Login to GitHub Container Registry
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
push: true
|
|
context: ./client
|
|
tags: ghcr.io/ricardo-campos-org/react-typescript-todolist/client:${{ github.event.number }}
|
|
build-args: BUILD=${{ github.event.number }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|