Skip to content

Commit

Permalink
Update GHA's
Browse files Browse the repository at this point in the history
See questions in PR descriptions
  • Loading branch information
snf2ye committed Jun 22, 2023
1 parent b397309 commit 015bd34
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 315 deletions.
152 changes: 72 additions & 80 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ jobs:
needs: [ build ]
runs-on: ubuntu-latest

services:
postgres:
image: postgres:13
env:
POSTGRES_PASSWORD: postgres
ports: [ "5432:5432" ]
# services:
# postgres:
# image: postgres:13
# env:
# POSTGRES_PASSWORD: postgres
# ports: [ "5432:5432" ]

steps:
- uses: actions/checkout@v3
Expand All @@ -117,85 +117,77 @@ jobs:
distribution: 'temurin'
cache: 'gradle'

- name: Make sure Postgres is ready and init
env:
PGPASSWORD: postgres
run: |
pg_isready -h localhost -t 10
psql -h localhost -U postgres -f ./common/postgres-init.sql
# - name: Make sure Postgres is ready and init
# env:
# PGPASSWORD: postgres
# run: |
# pg_isready -h localhost -t 10
# psql -h localhost -U postgres -f ./common/postgres-init.sql

- name: Test with coverage
run: ./gradlew --build-cache test jacocoTestReport

# The SonarQube scan is done here, so it can upload the coverage report generated by the tests.
# - name: SonarQube scan
# run: ./gradlew --build-cache sonarqube
# env:
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

integration-tests:
needs: [ build ]
runs-on: ubuntu-latest

services:
postgres:
image: postgres:13
env:
POSTGRES_PASSWORD: postgres
ports: [ "5432:5432" ]

steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'

- name: Make sure Postgres is ready and init
- name: SonarQube scan
run: ./gradlew --build-cache sonarqube
env:
PGPASSWORD: postgres
run: |
pg_isready -h localhost -t 10
psql -h localhost -U postgres -f ./common/postgres-init.sql
- name: Render GitHub Secrets
run: |
echo "${{ secrets.DEV_FIRECLOUD_ACCOUNT_B64 }}" | base64 -d > "integration/src/main/resources/rendered/user-delegated-sa.json"
echo "${{ secrets.PERF_TESTRUNNER_ACCOUNT_B64 }}" | base64 -d > "integration/src/main/resources/rendered/testrunner-perf.json"
- name: Launch the background process for integration tests
run: ./gradlew --build-cache bootRun | tee application.log &

- name: Wait for boot run to be ready
run: |
set +e
timeout 60 bash -c 'until echo > /dev/tcp/localhost/8080; do sleep 1; done'
resultStatus=$?
set -e
if [[ $resultStatus == 0 ]]; then
echo "Server started successfully"
else
echo "Server did not start successfully"
exit 1
fi
- name: Run the integration test suite
run: ./gradlew --build-cache runTest --args="suites/local/FullIntegration.json build/reports"

- name: Archive logs
id: archive_logs
if: always()
uses: actions/upload-artifact@v3
with:
name: application-logs
path: |
application.log
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# integration-tests:
# needs: [ build ]
# runs-on: ubuntu-latest
#
## services:
## postgres:
## image: postgres:13
## env:
## POSTGRES_PASSWORD: postgres
## ports: [ "5432:5432" ]
#
# steps:
# - uses: actions/checkout@v3
# - name: Set up JDK
# uses: actions/setup-java@v3
# with:
# java-version: '17'
# distribution: 'temurin'
# cache: 'gradle'
# - name: Render GitHub Secrets
# run: |
# echo "${{ secrets.DEV_FIRECLOUD_ACCOUNT_B64 }}" | base64 -d > "integration/src/main/resources/rendered/user-delegated-sa.json"
# echo "${{ secrets.PERF_TESTRUNNER_ACCOUNT_B64 }}" | base64 -d > "integration/src/main/resources/rendered/testrunner-perf.json"
#
# - name: Launch the background process for integration tests
# run: ./gradlew --build-cache bootRun | tee application.log &
#
# - name: Wait for boot run to be ready
# run: |
# set +e
# timeout 60 bash -c 'until echo > /dev/tcp/localhost/8080; do sleep 1; done'
# resultStatus=$?
# set -e
# if [[ $resultStatus == 0 ]]; then
# echo "Server started successfully"
# else
# echo "Server did not start successfully"
# exit 1
# fi
#
# - name: Run the integration test suite
# run: ./gradlew --build-cache runTest --args="suites/local/FullIntegration.json build/reports"
#
# - name: Archive logs
# id: archive_logs
# if: always()
# uses: actions/upload-artifact@v3
# with:
# name: application-logs
# path: |
# application.log

notify-slack:
needs: [ build, unit-tests-and-sonarqube, source-clear, integration-tests ]
needs: [ build, unit-tests-and-sonarqube, source-clear ]
runs-on: ubuntu-latest

if: failure() && github.ref == 'refs/heads/main'
Expand All @@ -206,15 +198,15 @@ jobs:
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
channel: '#jade-data-explorer'
channel: '#dsp-analysis-journeys-alerts'
status: failure
author_name: Build on dev
fields: job,message
text: 'Build failed :sadpanda:'
username: 'Data Explorer GitHub Action'
username: 'Java-PFB GitHub Action'

dispatch-tag:
needs: [ build, unit-tests-and-sonarqube, source-clear, integration-tests ]
needs: [ build, unit-tests-and-sonarqube, source-clear ]
runs-on: ubuntu-latest

if: success() && github.ref == 'refs/heads/main'
Expand Down
174 changes: 0 additions & 174 deletions .github/workflows/integration-tests.yml

This file was deleted.

Loading

0 comments on commit 015bd34

Please sign in to comment.