andrcuns/allure-report-publisher

View on GitHub
.github/workflows/test.yml

Summary

Maintainability
Test Coverage
name: Test

on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main

jobs:
  rubocop:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4.1.6
      - name: Set up Ruby 3.3
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: 3.3
          bundler-cache: true
      - name: Rubocop
        run: bundle exec rubocop --color

  rspec:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        ruby: ["3.1", "3.2", "3.3"]
    steps:
      - name: Checkout
        uses: actions/checkout@v4.1.6
      - name: Set up Ruby ${{ matrix.ruby }}
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: ${{ matrix.ruby }}
          bundler-cache: true
      - name: RSpec
        uses: paambaati/codeclimate-action@v9.0.0
        env:
          CC_TEST_REPORTER_ID: c782e3e534f6aac1bb5a0d595723167ed145d03567242c2ce848ef46ba36672a
          COVERAGE: "true"
          ALLURE_ENVIRONMENT: ruby-${{ matrix.ruby }}
        with:
          coverageCommand: bundle exec rspec --force-color
          coverageLocations: coverage/coverage.json:simplecov
      - uses: actions/upload-artifact@v4
        if: always()
        with:
          name: allure-reports-${{ matrix.ruby }}
          path: reports/allure-results/
          retention-days: 1

  publish-report:
    runs-on: ubuntu-latest
    needs: rspec
    if: always()
    name: publish report as ${{ matrix.results }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - table: markdown
            results: description
          - table: ascii
            results: comment
          - table: markdown
            results: actions
    steps:
      - name: Checkout
        uses: actions/checkout@v4.1.6
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3.7.1
      - name: Build
        uses: docker/build-push-action@v6.9.0
        with:
          context: .
          push: false
          load: true
          tags: publisher:latest
          cache-from: type=gha
          cache-to: type=gha,mode=max
      - name: Download allure reports
        uses: actions/download-artifact@v4
        with:
          path: reports/allure-results
      - name: Cache minio store
        id: cache-primes-restore
        uses: actions/cache@v4
        with:
          path: minio
          key: minio/${{ github.ref_name }}/${{ github.run_id }}
          restore-keys: minio/${{ github.ref_name }}
      - name: Set up Minio
        run: |
          mkdir -p minio/allure-reports
          docker network create allure
          docker run -d \
          --name minio \
          --network allure \
          --volume "$(pwd)/minio":/data \
          quay.io/minio/minio:latest \
          server /data
      - name: Publish allure report
        env:
          GITHUB_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          docker run --rm \
            -v "$(pwd)":/workspace \
            -v "$GITHUB_STEP_SUMMARY:$GITHUB_STEP_SUMMARY" \
            -v "$GITHUB_EVENT_PATH:$GITHUB_EVENT_PATH" \
            -e GITHUB_WORKFLOW="$GITHUB_WORKFLOW" \
            -e GITHUB_EVENT_NAME="$GITHUB_EVENT_NAME" \
            -e GITHUB_EVENT_PATH="$GITHUB_EVENT_PATH" \
            -e GITHUB_SERVER_URL="$GITHUB_SERVER_URL" \
            -e GITHUB_API_URL="$GITHUB_API_URL" \
            -e GITHUB_REPOSITORY="$GITHUB_REPOSITORY" \
            -e GITHUB_RUN_ID="$GITHUB_RUN_ID" \
            -e GITHUB_SHA="$GITHUB_SHA" \
            -e GITHUB_AUTH_TOKEN="$GITHUB_AUTH_TOKEN" \
            -e GITHUB_STEP_SUMMARY="$GITHUB_STEP_SUMMARY" \
            -e AWS_ENDPOINT="http://minio:9000" \
            -e AWS_FORCE_PATH_STYLE="true" \
            -e AWS_ACCESS_KEY_ID="minioadmin" \
            -e AWS_SECRET_ACCESS_KEY="minioadmin" \
            -e ALLURE_JOB_NAME="rspec" \
            --network allure \
            publisher:latest \
            upload s3 \
              --results-glob="/workspace/reports/allure-results/*" \
              --bucket="allure-reports" \
              --prefix="allure-report-publisher/$GITHUB_REF" \
              --update-pr="${{ matrix.results }}" \
              --summary="behaviors" \
              --summary-table-type="${{ matrix.table }}" \
              --report-title="Test Report" \
              --report-name="Test Report" \
              --copy-latest \
              --color \
              --debug