-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (102 loc) · 3.33 KB
/
main.yml
File metadata and controls
110 lines (102 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: A workflow for my SQL App
on: push
# Give GitHub Actions permission to create/update tags
permissions:
contents: write
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 verify -Dtest=AppTest,CountryReportTest,CityReportTest,CapitalCityReportTest,LanguageReportTest,UrbanReportTest
- name: Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./target/site/jacoco/jacoco.xml
flags: unit
verbose: true
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,LanguageReportIntegrationTest,UrbanReportIntegration
docker stop world
docker rm world
docker image rm database
- name: 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
# Only run this job when pushing to master
if: github.ref == 'refs/heads/master'
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
- name: Create Github Release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
automatic_release_tag: "latest"
files: |
./target/*.jar
- name: Copy Output
run: docker container cp devops-app:./tmp/reports ./
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4.2.5
with:
branch: reports # The branch the action should deploy to.
folder: reports # The folder we are copying