Files
tasknote/.github/workflows/pr.yml
T
rmcamposandGitHub 32969dc861 fix: loggin issues (#319)
* fix: loggin issues

closes #302

feat: improve build number in docker image

* test: fix integration test for the taskController

* test: add unit test to taskService

* test: add more unit tests to taskService

* test: add delete unit tests for taskService

* test: add patch unit tests for taskService
2025-03-02 18:45:36 -03:00

187 lines
5.9 KiB
YAML

name: PR
on:
pull_request:
concurrency:
group: ${{ github.event.number }}
cancel-in-progress: true
jobs:
# JOB to run change detection
changes:
name: Check changes
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
server: ${{ steps.filter.outputs.server }}
client: ${{ steps.filter.outputs.client }}
steps:
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
server:
- 'server/**'
client:
- 'client/**'
client-code-checks:
needs: changes
if: ${{ needs.changes.outputs.client == 'true' }}
name: Client Code Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
name: Set up Node
with:
node-version: '22'
- 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
- name: SonarCloud Scan
uses: SonarSource/sonarqube-scan-action@v5.0.0
with:
projectBaseDir: client
args: >
-Dsonar.organization=ricardo-campos-org
-Dsonar.projectKey=ricardo-campos-org_react-typescript-todolist_client
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
-Dsonar.typescript.tsconfigPaths=tsconfig.json
-Dsonar.sources=src/
-Dsonar.exclusions=src/__test__/**
-Dsonar.tests=src/__test__/
-Dsonar.verbose=false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
client-docker-build:
name: Build Client Docker image
runs-on: ubuntu-latest
needs: client-code-checks
env:
VITE_BUILD: client:${{ github.event.number }}
VITE_BACKEND_SERVER: ${{ secrets.SERVER_ADDRESS }}/server
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: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d-%H%M%S')" >> $GITHUB_OUTPUT
- 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=v${{ github.event.number }}-${{ github.run_id }}-${{ steps.date.outputs.date }}
cache-from: type=gha
cache-to: type=gha,mode=max
java-code-checks:
needs: changes
if: ${{ needs.changes.outputs.server == 'true' }}
name: Server Code Checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Cache SonarQube Cloud packages
uses: actions/cache@v4.2.1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v4.2.1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build with Maven
run: cd server && ./mvnw --no-transfer-progress clean compile -DskipTests
- name: Google Check-Style
run: cd server && ./mvnw --no-transfer-progress checkstyle:checkstyle -Dskip.checkstyle=false
- name: Unit and Integration tests
run: |
cd server
./mvnw --no-transfer-progress clean verify -P tests --file pom.xml
- name: Sonar Analysis
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_SERVER }}
run: |
cd server
./mvnw -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=br.com.tasknoteapp:server -Dsonar.coverage.jacoco.xmlReportPaths=target/coverage-reports/merged-test-report/jacoco.xml -Dsonar.exclusions='**/config/**,**/entity/**,**/exception/**,**/filter/**,**/**Builder*,**/RestExceptionEndpoint.*,**/JavaApiApiApplication.*'
java-docker-build:
name: Build Server Docker image
runs-on: ubuntu-latest
needs: java-code-checks
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: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d-%H%M%S')" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
context: ./server
tags: ghcr.io/ricardo-campos-org/react-typescript-todolist/server:${{ github.event.number }}
build-args: |
BUILD=v${{ github.event.number }}-${{ github.run_id }}-${{ steps.date.outputs.date }}
cache-from: type=gha
cache-to: type=gha,mode=max