name: Run Tests env: GIT_AUTHOR_EMAIL: "packages@datadoghq.com" GIT_AUTHOR_NAME: "ci.datadog-api-spec" on: pull_request: branches: - master concurrency: group: unit-${{ github.head_ref }} cancel-in-progress: true jobs: pre-commit: runs-on: ubuntu-latest if: > github.event.pull_request.draft == false && !contains(github.event.pull_request.labels.*.name, 'ci/skip') && !contains(github.event.pull_request.head.ref, 'datadog-api-spec/test/') steps: - name: Get GitHub App token id: get_token uses: tibdex/github-app-token@v1 with: app_id: ${{ secrets.PIPELINE_GITHUB_APP_ID }} private_key: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }} - uses: actions/checkout@v2 with: fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha }} token: ${{ steps.get_token.outputs.token }} - name: Install pre-commit run: python -m pip install pre-commit - name: set PY run: echo "PY=$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_ENV - uses: actions/cache@v2 with: path: ~/.cache/pre-commit key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} - id: pre_commit name: Run pre-commit if: github.event.action != 'closed' && github.event.pull_request.merged != true run: | pre-commit run --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }} --show-diff-on-failure --color=always - name: Commit changes if: ${{ failure() }} run: |- git add -A git config user.name "${GIT_AUTHOR_NAME}" git config user.email "${GIT_AUTHOR_EMAIL}" git commit -m "pre-commit fixes" git push origin HEAD:${{ github.event.pull_request.head.ref }} exit 1 test: strategy: matrix: ruby-version: ["2.5", "2.6", "2.7"] platform: [ubuntu-latest, macos-latest] # , windows-latest] # test only latest version on macos and windows exclude: - platform: macos-latest ruby-version: "2.5" - platform: macos-latest ruby-version: "2.6" # - platform: windows-latest # ruby-version: '2.5' # - platform: windows-latest # ruby-version: '2.6' runs-on: ${{ matrix.platform }} if: github.event.pull_request.draft == false && !contains(github.event.pull_request.labels.*.name, 'ci/skip') && !contains(github.event.pull_request.head.ref, 'datadog-api-spec/test/') steps: - uses: actions/checkout@v2 - name: Set up Ruby ${{ matrix.ruby-version }} uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true # modify repository secret when there are problems with installing gems cache-version: ${{ secrets.CACHE_VERSION }} - name: Test run: ./run-tests.sh shell: bash examples: runs-on: ubuntu-latest if: github.event.pull_request.draft == false && !contains(github.event.pull_request.labels.*.name, 'ci/skip') && !contains(github.event.pull_request.head.ref, 'datadog-api-spec/test/') steps: - uses: actions/checkout@v2 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: ruby-version: "2.7" bundler-cache: true # modify repository secret when there are problems with installing gems cache-version: ${{ secrets.CACHE_VERSION }} - name: Check examples run: ./check-examples.sh shell: bash report: runs-on: ubuntu-latest if: always() && github.event_name == 'pull_request' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/') needs: - test - examples steps: - name: Get GitHub App token if: github.event_name == 'pull_request' id: get_token uses: tibdex/github-app-token@v1 with: app_id: ${{ secrets.PIPELINE_GITHUB_APP_ID }} private_key: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }} repository: DataDog/datadog-api-spec - name: Checkout code uses: actions/checkout@v2 - name: Post status check uses: DataDog/github-actions/post-status-check@v1.0.0 with: github-token: ${{ steps.get_token.outputs.token }} repo: datadog-api-spec status: ${{ needs.test.result == 'success' && needs.examples.result == 'success' && 'success' || 'failure' }} context: unit