Merge branch 'feature-branch' into develop #192
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: A workflow for my SQL App | |
| on: push | |
| jobs: | |
| UnitTests: | |
| name: Unit Tests | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v2 | |
| with: | |
| java-version: '17' | |
| distribution: 'adopt' | |
| - name: Unit Tests | |
| run: mvn -Dtest=AppTest,CountryReportTest,CityReportTest,CapitalCityReportTest test | |
| IntegrationTests: | |
| name: Integration Tests | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'adopt' | |
| - name: Integration Tests and CodeCov | |
| run: | | |
| docker build -t database ./db | |
| docker run --name world -e MYSQL_ROOT_PASSWORD=example -d -p 3308:3306 database | |
| MAX_TRIES=12 | |
| TRIES=0 | |
| until docker exec world mysqladmin ping --silent; do | |
| echo "Waiting for database to be ready..." | |
| sleep 5 | |
| TRIES=$((TRIES+1)) | |
| if [ $TRIES -ge $MAX_TRIES ]; then | |
| echo "Database did not start in time" | |
| docker logs world | |
| exit 1 | |
| fi | |
| done | |
| mvn verify -Dtest=com.napier.devops.AppIntegrationTest,CountryReportIntegrationTest,CityReportIntegrationTest,CapitalCityReportIntegrationTest | |
| docker stop world | |
| docker rm world | |
| docker image rm database | |
| - name: Upload coverage reports to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: ./target/site/jacoco/jacoco.xml | |
| flags: integration | |
| verbose: true | |
| build: | |
| name: Build and Start Using docker-compose | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'adopt' | |
| - name: Package and Run docker compose | |
| run: | | |
| mvn package -DskipTests | |
| docker compose up --abort-on-container-exit |