Updated yml with docker #4
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: Run & Deploy Reports to GitHub Pages | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| jobs: | |
| run-tests: | |
| timeout-minutes: 60 | |
| name: Run Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Start Docker Services | |
| run: docker compose -f .github/workflows/docker-compose-h2.yml up -d | |
| - name: Set up Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Cache Maven Packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.m2 | |
| key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-m2 | |
| - name: Install Dependencies | |
| run: mvn install -DskipTests | |
| - name: Set up Xvfb (for GUI applications, if needed) | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y xvfb | |
| Xvfb :99 & # Start Xvfb on display :99 | |
| export DISPLAY=:99 # Set the DISPLAY environment variable | |
| - name: Run Selenium Tests | |
| run: | | |
| export DISPLAY=:99 # Ensure DISPLAY is set | |
| mvn test | |
| - name: Archive Test Reports | |
| uses: actions/upload-artifact@v4 | |
| if: ${{ always() }} # Ensures this step runs even if tests fail | |
| with: | |
| name: Reports | |
| path: target/chaintest/ # Archive the entire chaintest directory | |
| retention-days: 7 # Set the retention period to 7 days | |
| - name: Stop Docker Services | |
| if: always() | |
| run: docker compose -f .github/workflows/docker-compose-h2.yml down | |
| deploy-pages: | |
| name: Deploy Reports to GitHub Pages | |
| runs-on: ubuntu-latest | |
| if: ${{ always() }} # Ensures this step runs even if tests fail | |
| needs: run-tests | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Download Test Reports | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: Reports | |
| path: ./target/chaintest | |
| - name: Prepare Report for Deployment | |
| run: | | |
| mkdir -p public | |
| cp -R target/chaintest/* public/ | |
| mv public/Index.html public/index.html # Ensure index.html for GitHub Pages | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
| publish_dir: ./public # Deploy the prepared report and data | |
| force_orphan: true # Create a new commit every time |