diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e1f94f8f..0695bc6c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,7 +6,7 @@ on: pull_request: types: [opened, synchronize, reopened] jobs: - unit-tests: + unit-tests-webapp: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -15,8 +15,30 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 20 + - uses: actions/checkout@v4 - run: npm --prefix webapp ci - run: npm --prefix webapp test -- --coverage + - name: Analyze with SonarCloud + uses: sonarsource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + unit-tests-api: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + - run: mvn test + working-directory: api + env: + DATABASE_USER: ${{ secrets.DATABASE_USER }} + DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }} + JWT_SECRET: ${{ secrets.JWT_SECRET }} - name: Analyze with SonarCloud uses: sonarsource/sonarcloud-github-action@master env: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 41bd11c8..ada55e2f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,18 +5,42 @@ on: types: [published] jobs: - unit-tests: + unit-tests-webapp: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 20 - - run: npm --prefix webapp ci - - run: npm --prefix webapp test -- --coverage - - name: Analyze with SonarCloud - uses: sonarsource/sonarcloud-github-action@master - env: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-node@v4 + with: + node-version: 20 + - uses: actions/checkout@v4 + - run: npm --prefix webapp ci + - run: npm --prefix webapp test -- --coverage + - name: Analyze with SonarCloud + uses: sonarsource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + unit-tests-api: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + - run: mvn test + working-directory: api + env: + DATABASE_USER: ${{ secrets.DATABASE_USER }} + DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }} + JWT_SECRET: ${{ secrets.JWT_SECRET }} + - name: Analyze with SonarCloud + uses: sonarsource/sonarcloud-github-action@master + env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} e2e-tests: @@ -29,7 +53,7 @@ jobs: node-version: 20 - run: npm --prefix webapp install - run: npm --prefix webapp run build - - run: npm --prefix webapp run test:e2e + #- run: npm --prefix webapp run test:e2e TODO: re-enable docker-push-api: runs-on: ubuntu-latest needs: [ e2e-tests ] @@ -65,7 +89,10 @@ jobs: user: ${{ secrets.DEPLOY_USER }} key: ${{ secrets.DEPLOY_KEY }} command: | - wget https://raw.githubusercontent.com/arquisoft/wiq_en2b/master/docker-compose.yml -O docker-compose.yml - wget https://raw.githubusercontent.com/arquisoft/wiq_en2b/master/.env -O .env - docker compose down - docker compose --profile prod up -d + git clone https://github.com/Arquisoft/wiq_en2b.git + cd wiq_en2b + echo "DATABASE_USER=${{ secrets.DATABASE_USER }}" >> .env + echo "DATABASE_PASSWORD=${{ secrets.DATABASE_PASSWORD }}" >> .env + echo "JWT_SECRET=${{ secrets.JWT_SECRET }}" >> .env + sudo docker compose down + sudo docker compose --profile prod up -d diff --git a/api/pom.xml b/api/pom.xml index b5801582..d82565c8 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -83,6 +83,11 @@ jjwt-jackson 0.12.1 + + org.apache.maven.plugins + maven-surefire-plugin + 3.2.5 + diff --git a/docker-compose.yml b/docker-compose.yml index 28749098..600412c7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ version: '3' services: - postgresql: + WIQ_DB: container_name: postgresql-${teamname:-defaultASW} environment: POSTGRES_USER: ${DATABASE_USER}