@@ -12,21 +12,37 @@ jobs:
1212 name : Run Tests
1313 runs-on : ubuntu-latest
1414 steps :
15+ # Step 1: Checkout the repository
1516 - name : Checkout Code
1617 uses : actions/checkout@v4
1718
19+ # Step 2: Set up Docker
1820 - name : Set up Docker
1921 uses : docker/setup-buildx-action@v2
2022
23+ # Step 3: Start ChainTest service with Docker Compose
2124 - name : Start Docker Services
22- run : docker compose -f .github/workflows/docker-compose-h2.yml up -d
25+ run : |
26+ docker compose -f .github/workflows/docker-compose-h2.yml up -d
27+ sleep 15 # Wait for the ChainTest service to start completely
28+
29+ # Step 4: Verify ChainTest service is running
30+ - name : Verify ChainTest is Running
31+ run : |
32+ curl --fail http://localhost:85/ || exit 1
33+ env :
34+ SPRING_PROFILES_ACTIVE : h2
35+ SPRING_DATASOURCE_URL : jdbc:h2:file:./data/db
36+ SPRING_DATASOURCE_DRIVERCLASSNAME : org.h2.Driver
2337
38+ # Step 5: Set up Java (Temurin 17)
2439 - name : Set up Java
2540 uses : actions/setup-java@v4
2641 with :
2742 java-version : ' 17'
2843 distribution : ' temurin'
2944
45+ # Step 6: Cache Maven packages for faster builds
3046 - name : Cache Maven Packages
3147 uses : actions/cache@v4
3248 with :
@@ -35,62 +51,70 @@ jobs:
3551 restore-keys : |
3652 ${{ runner.os }}-m2
3753
54+ # Step 7: Install project dependencies
3855 - name : Install Dependencies
3956 run : mvn install -DskipTests
4057
41- - name : Set up Xvfb (for GUI applications, if needed)
58+ # Step 8: Set up Xvfb (if GUI applications like Selenium require it)
59+ - name : Set up Xvfb
4260 run : |
4361 sudo apt-get update
4462 sudo apt-get install -y xvfb
4563 Xvfb :99 & # Start Xvfb on display :99
46- export DISPLAY=:99 # Set the DISPLAY environment variable
64+ export DISPLAY=:99 # Set DISPLAY variable for GUI apps
4765
66+ # Step 9: Run Selenium tests
4867 - name : Run Selenium Tests
4968 run : |
5069 export DISPLAY=:99 # Ensure DISPLAY is set
5170 mvn test
71+ env :
72+ DISPLAY : :99 # Ensure the same environment variable is available
5273
74+ # Step 10: Archive test reports
5375 - name : Archive Test Reports
5476 uses : actions/upload-artifact@v4
55- if : ${{ always() }} # Ensures this step runs even if tests fail
77+ if : ${{ always() }} # Run this step even if tests fail
5678 with :
5779 name : Reports
5880 path : target/chaintest/ # Archive the entire chaintest directory
59- retention-days : 7 # Set the retention period to 7 days
81+ retention-days : 7
6082
83+ # Step 11: Stop Docker services
6184 - name : Stop Docker Services
6285 if : always()
6386 run : docker compose -f .github/workflows/docker-compose-h2.yml down
6487
6588 deploy-pages :
6689 name : Deploy Reports to GitHub Pages
6790 runs-on : ubuntu-latest
68- if : ${{ always() }} # Ensures this step runs even if tests fail
91+ if : ${{ always() }} # Ensure this step runs even if tests fail
6992 needs : run-tests
7093 permissions :
7194 contents : write
7295
7396 steps :
97+ # Step 1: Checkout the repository
7498 - name : Checkout Code
7599 uses : actions/checkout@v4
76100
101+ # Step 2: Download archived test reports
77102 - name : Download Test Reports
78103 uses : actions/download-artifact@v4
79104 with :
80105 name : Reports
81106 path : ./target/chaintest
82107
108+ # Step 3: Prepare reports for deployment
83109 - name : Prepare Report for Deployment
84110 run : |
85111 mkdir -p public
86112 cp -R target/chaintest/* public/
87113 mv public/Index.html public/index.html # Ensure index.html for GitHub Pages
88114
89- - name : Deploy to GitHub Pages
115+ # Step 4 : Deploy reports to GitHub Pages
90116 uses : peaceiris/actions-gh-pages@v3
91117 with :
92118 github_token : ${{ secrets.GH_TOKEN }}
93- publish_dir : ./public # Deploy the prepared report and data
94- force_orphan : true # Create a new commit every time
95-
96-
119+ publish_dir : ./public
120+ force_orphan : true
0 commit comments