install lein #34
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: BUILD | ||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| pull_request: | ||
| workflow_dispatch: | ||
| jobs: | ||
| job-build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| with: | ||
| # Disabling shallow clone is recommended for improving relevancy of reporting for sonar | ||
| fetch-depth: 0 | ||
| - name: Cache local Maven repository | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.m2/repository | ||
| key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-maven- | ||
| - name: Cache local Maven repository | ||
| - name: Set up JDK 11 | ||
| uses: actions/setup-java@v2 | ||
| with: | ||
| distribution: 'zulu' | ||
| java-version: '11' | ||
| - name: Install clojure tools | ||
| uses: DeLaGuardo/setup-clojure@12.5 | ||
| with: | ||
| lein: 2.11.2 | ||
| - name: Setup Sonar Scanner | ||
| uses: warchant/setup-sonar-scanner@v3 | ||
| with: | ||
| version: 5.0.2.4997 | ||
| - name: Run Sonar Scanner | ||
| env: | ||
| # provide GITHUB_TOKEN to get access to secrets.SONAR_TOKEN | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: sonar-scanner | ||
| -Dsonar.token=${{ secrets.SONARQUBE_TOKEN}} | ||
| -Dsonar.host.url=${{ secrets.SONAR_HOST_URL }} | ||
| - name: Get list of tests | ||
| if: always() | ||
| id: tests | ||
| uses: Rishabh510/Path-lister-action@master | ||
| with: | ||
| path: "test-reports" | ||
| type: ".xml" | ||
| - name: Fail on failed tests | ||
| if: always() | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y libxml2-utils | ||
| echo "Found ${{ steps.tests.outputs.path_count }} test report(s)" | ||
| if [[ ${{ steps.tests.outputs.path_count }} < 1 ]]; then | ||
| echo "ERROR: No unit test reports collected." | ||
| exit 1 | ||
| fi | ||
| for f in ${{ steps.tests.outputs.paths }}; do | ||
| echo "=== $f ===" | ||
| if [[ $(xmllint --xpath "string(//testsuite/@failures)" $f) > 1 ]]; then | ||
| echo TEST FAILED: $f | ||
| exit 1 | ||
| fi | ||
| if [[ $(xmllint --xpath "string(//testsuite/@errors)" $f) > 1 ]]; then | ||
| echo TEST ERRORED: $f | ||
| exit 1 | ||
| fi | ||
| done | ||
| - name: SonarQube Quality Gate check | ||
| uses: sonarsource/sonarqube-quality-gate-action@v1.0.0 | ||
| # Force to fail step after specific time | ||
| timeout-minutes: 5 | ||
| with: | ||
| scanMetadataReportFile: .scannerwork/report-task.txt | ||
| env: | ||
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
| SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} | ||
| - uses: s4u/maven-settings-action@v2.2.0 | ||
| with: | ||
| githubServer: false | ||
| override: true | ||
| servers: | | ||
| [{ | ||
| "id": "docker.io", | ||
| "username": "${{ secrets.SIXSQ_DOCKER_USERNAME }}", | ||
| "password": "${{ secrets.SIXSQ_DOCKER_PASSWORD }}" | ||
| }] | ||
| - name: Extract branch name | ||
| shell: bash | ||
| run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF##*/})" | ||
| id: extract_branch | ||
| - name: Build | ||
| env: | ||
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
| run: lein do clean, jar, install | ||
| - name: Deploy | ||
| env: | ||
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
| run: lein deploy | ||
| - name: Publish Unit Test Results | ||
| uses: EnricoMi/publish-unit-test-result-action@v1 | ||
| if: always() | ||
| with: | ||
| files: test-reports/TEST-*.xml | ||
| job-notify: | ||
| if: always() | ||
| name: Post Workflow Status To Slack | ||
| needs: | ||
| - job-build | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: Gamesight/slack-workflow-status@master | ||
| with: | ||
| repo_token: ${{secrets.GITHUB_TOKEN}} | ||
| slack_webhook_url: ${{secrets.SLACK_WEBHOOK_URL}} | ||