|
| 1 | +name: Run & Deploy Reports to GitHub Pages |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + run-tests: |
| 11 | + timeout-minutes: 60 |
| 12 | + name: Run Tests |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Checkout Code |
| 16 | + uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Set up Docker |
| 19 | + uses: docker/setup-buildx-action@v2 |
| 20 | + |
| 21 | + - name: Start Docker Services |
| 22 | + run: docker compose -f docker-compose-h2.yml up -d |
| 23 | + |
| 24 | + - name: Set up Java |
| 25 | + uses: actions/setup-java@v4 |
| 26 | + with: |
| 27 | + java-version: '17' |
| 28 | + distribution: 'temurin' |
| 29 | + |
| 30 | + - name: Cache Maven Packages |
| 31 | + uses: actions/cache@v4 |
| 32 | + with: |
| 33 | + path: ~/.m2 |
| 34 | + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} |
| 35 | + restore-keys: | |
| 36 | + ${{ runner.os }}-m2 |
| 37 | +
|
| 38 | + - name: Install Dependencies |
| 39 | + run: mvn install -DskipTests |
| 40 | + |
| 41 | + - name: Set up Xvfb (for GUI applications, if needed) |
| 42 | + run: | |
| 43 | + sudo apt-get update |
| 44 | + sudo apt-get install -y xvfb |
| 45 | + Xvfb :99 & # Start Xvfb on display :99 |
| 46 | + export DISPLAY=:99 # Set the DISPLAY environment variable |
| 47 | +
|
| 48 | + - name: Run Selenium Tests |
| 49 | + run: | |
| 50 | + export DISPLAY=:99 # Ensure DISPLAY is set |
| 51 | + mvn test |
| 52 | +
|
| 53 | + - name: Archive Test Reports |
| 54 | + uses: actions/upload-artifact@v4 |
| 55 | + if: ${{ always() }} # Ensures this step runs even if tests fail |
| 56 | + with: |
| 57 | + name: Reports |
| 58 | + path: target/chaintest/ # Archive the entire chaintest directory |
| 59 | + retention-days: 7 # Set the retention period to 7 days |
| 60 | + |
| 61 | + - name: Stop Docker Services |
| 62 | + if: always() |
| 63 | + run: docker compose -f docker-compose-h2.yml down |
| 64 | + |
| 65 | + deploy-pages: |
| 66 | + name: Deploy Reports to GitHub Pages |
| 67 | + runs-on: ubuntu-latest |
| 68 | + if: ${{ always() }} # Ensures this step runs even if tests fail |
| 69 | + needs: run-tests |
| 70 | + permissions: |
| 71 | + contents: write |
| 72 | + |
| 73 | + steps: |
| 74 | + - name: Checkout Code |
| 75 | + uses: actions/checkout@v4 |
| 76 | + |
| 77 | + - name: Download Test Reports |
| 78 | + uses: actions/download-artifact@v4 |
| 79 | + with: |
| 80 | + name: Reports |
| 81 | + path: ./target/chaintest |
| 82 | + |
| 83 | + - name: Prepare Report for Deployment |
| 84 | + run: | |
| 85 | + mkdir -p public |
| 86 | + cp -R target/chaintest/* public/ |
| 87 | + mv public/Index.html public/index.html # Ensure index.html for GitHub Pages |
| 88 | +
|
| 89 | + - name: Deploy to GitHub Pages |
| 90 | + uses: peaceiris/actions-gh-pages@v3 |
| 91 | + with: |
| 92 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 93 | + publish_dir: ./public # Deploy the prepared report and data |
| 94 | + force_orphan: true # Create a new commit every time |
0 commit comments