|
| 1 | +name: Java CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - '*' |
| 8 | + branches: |
| 9 | + - develop |
| 10 | + |
| 11 | +jobs: |
| 12 | + build_and_test: |
| 13 | + strategy: |
| 14 | + fail-fast: false |
| 15 | + matrix: |
| 16 | + os: [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ] |
| 17 | + java-version: [ 11 ] |
| 18 | + browser: ['googlechromeheadless', 'firefoxheadless', 'edgeheadless'] |
| 19 | + include: |
| 20 | + - os: ubuntu-latest |
| 21 | + set_display: export DISPLAY=:99; Xvfb :99 -screen 0 1024x768x24 -ac -noreset & sleep 3 |
| 22 | + install_dependencies: | |
| 23 | + curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg |
| 24 | + sudo install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/ |
| 25 | + sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge-dev.list' |
| 26 | + sudo rm microsoft.gpg |
| 27 | + sudo apt update |
| 28 | + sudo apt-get -y -q install xvfb zip curl microsoft-edge-beta |
| 29 | + - os: windows-latest |
| 30 | + install_dependencies: choco install firefox googlechrome curl zip -y --no-progress |
| 31 | + - os: macos-latest |
| 32 | + install_dependencies: | |
| 33 | + brew install --cask firefox |
| 34 | + brew install --cask google-chrome |
| 35 | + brew install --cask microsoft-edge |
| 36 | + brew install zip |
| 37 | + brew install curl |
| 38 | + exclude: |
| 39 | + - os: macos-latest |
| 40 | + browser: firefoxheadless # Webdriver download if not working with Firefox at GHA |
| 41 | + java-version: 8 |
| 42 | + |
| 43 | + runs-on: ${{ matrix.os }} |
| 44 | + name: Test on ${{ matrix.os }} with Java ${{ matrix.java-version }} using browser ${{ matrix.browser }} |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v2 |
| 47 | + - name: Set up JDK ${{ matrix.java-version }} |
| 48 | + uses: actions/setup-java@v2.3.0 |
| 49 | + with: |
| 50 | + distribution: zulu |
| 51 | + java-version: ${{ matrix.java-version }} |
| 52 | + java-package: jdk+fx # needed for jbrowser |
| 53 | + - name: Set up other dependencies |
| 54 | + run: | |
| 55 | + ${{ matrix.install_dependencies }} |
| 56 | + ${{ matrix.set_display }} |
| 57 | + - name: Build with Maven |
| 58 | + run: | |
| 59 | + mvn -B -ntp -q verify --file pom.xml -P 'build,${{ matrix.browser }}' |
| 60 | + - name: Delete output.xml (on Win) |
| 61 | + run: | |
| 62 | + Get-ChildItem target/robotframework-reports -Include *output.xml -Recurse | Remove-Item |
| 63 | + echo "REPORT_FILE=$(Get-ChildItem target/robotframework-reports -Include *report.html -Recurse -Name)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 64 | + echo "SHA=$(("${{ github.event_name }}" -eq "push") ? '${{ github.sha }}' : '${{ github.event.pull_request.head.sha }}')" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 65 | + if: always() && runner.os == 'Windows' |
| 66 | + |
| 67 | + - name: Delete output.xml (on Unix-like) |
| 68 | + run: | |
| 69 | + find target/robotframework-reports -type f -name '*output.xml' -exec rm {} + |
| 70 | + echo "REPORT_FILE=$(find target/robotframework-reports -type f -name '*report.html' | sed 's#.*/##')" >> $GITHUB_ENV |
| 71 | + echo "SHA=$([ "${{ github.event_name }}" == "push" ] && echo "${{ github.sha }}" || echo "${{ github.event.pull_request.head.sha }}")" >> $GITHUB_ENV |
| 72 | + if: always() && runner.os != 'Windows' |
| 73 | + |
| 74 | + - name: Print actual triggering commit |
| 75 | + run: echo "${{ env.SHA }}" |
| 76 | + |
| 77 | + - name: Archive acceptances test results |
| 78 | + uses: actions/upload-artifact@v2.2.4 |
| 79 | + with: |
| 80 | + name: at-results-${{ matrix.browser }}-${{ matrix.os }}-${{ matrix.java-version }} |
| 81 | + path: target/robotframework-reports |
| 82 | + if: always() && job.status == 'failure' |
| 83 | + |
| 84 | + - name: Upload results on failure |
| 85 | + id: upload_results |
| 86 | + run: | |
| 87 | + echo '<html><head><meta http-equiv = "refresh" content =" 0 ; url = /${{ env.REPORT_FILE }}"></head></html>' > target/robotframework-reports/index.html |
| 88 | + zip -r -j site.zip target/robotframework-reports > no_output 2>&1 |
| 89 | + curl -s -H "Content-Type: application/zip" -H "Authorization: Bearer ${{ secrets.NETLIFY_TOKEN }}" --data-binary "@site.zip" https://api.netlify.com/api/v1/sites > response.json |
| 90 | + echo "::set-output name=REPORT_URL::$(cat response.json|python -c "import sys, json; print('https://' + json.load(sys.stdin)['subdomain'] + '.netlify.com')")" |
| 91 | + echo "::set-output name=JOB_STATUS::$(python -c "print('${{ job.status }}'.lower())")" |
| 92 | + if: always() && job.status == 'failure' |
| 93 | + |
| 94 | + - uses: octokit/request-action@7e93b91076fad3920c29d44eb2a6311d929db3dd |
| 95 | + name: Update status with Github Status API |
| 96 | + id: update_status_pr |
| 97 | + with: |
| 98 | + route: POST /repos/{repository}/statuses/{sha} |
| 99 | + repository: ${{ github.repository }} |
| 100 | + sha: "${{env.SHA}}" |
| 101 | + state: "${{steps.upload_results.outputs.JOB_STATUS}}" |
| 102 | + target_url: "${{steps.upload_results.outputs.REPORT_URL}}" |
| 103 | + description: "Link to test report." |
| 104 | + context: at-results-${{ matrix.browser }}-${{ matrix.os }}-${{ matrix.java-version }} |
| 105 | + env: |
| 106 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 107 | + if: always() && job.status == 'failure' |
| 108 | + |
| 109 | + release: |
| 110 | + needs: [build_and_test] |
| 111 | + if: github.event_name == 'push' |
| 112 | + runs-on: ubuntu-latest |
| 113 | + name: Release package |
| 114 | + steps: |
| 115 | + - uses: actions/checkout@v2 |
| 116 | + - name: Set up JDK |
| 117 | + uses: actions/setup-java@v2.3.0 |
| 118 | + with: |
| 119 | + distribution: zulu |
| 120 | + java-version: 11 |
| 121 | + - name: Release Maven package |
| 122 | + uses: samuelmeuli/action-maven-publish@201a45a3f311b2ee888f252ba9f4194257545709 |
| 123 | + with: |
| 124 | + gpg_private_key: ${{ secrets.gpg_private_key }} |
| 125 | + gpg_passphrase: ${{ secrets.gpg_passphrase }} |
| 126 | + nexus_username: ${{ secrets.nexus_username }} |
| 127 | + nexus_password: ${{ secrets.nexus_password }} |
| 128 | + maven_args: -DskipTests -B -ntp |
0 commit comments