Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
percy-issue-comment.yml 4.47 KiB
# Triggers Percy job by "@metabase-bot run visual tests" comment in a PR
name: PercyIssueComment

on:
  issue_comment:
    types: [created]

jobs:
  pr_info:
    if: github.event.comment.body == '@metabase-bot run visual tests'
    runs-on: ubuntu-20.04
    outputs:
      pull_request_number: ${{ fromJson(steps.fetch_pr.outputs.data).head.number }}
      branch_name: ${{ fromJson(steps.fetch_pr.outputs.data).head.ref }}
      commit_sha: ${{ fromJson(steps.fetch_pr.outputs.data).head.sha }}
    steps:
      - name: Fetch issue
        uses: octokit/request-action@v2.x
        id: fetch_issue
        with:
          route: GET ${{ github.event.issue.url }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Fetch PR
        uses: octokit/request-action@v2.x
        id: fetch_pr
        with:
          route: GET ${{ fromJson(steps.fetch_issue.outputs.data).pull_request.url }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  build:
    runs-on: ubuntu-20.04
    needs: pr_info
    timeout-minutes: 60
    strategy:
      matrix:
        edition: [oss]
    env:
      MB_EDITION: ${{ matrix.edition }}
      INTERACTIVE: false
    steps:
      - uses: actions/checkout@v2
        with:
          ref: ${{ needs.pr_info.outputs.branch_name }}
          token: ${{ secrets.GITHUB_TOKEN }}
      - name: Prepare Node.js
        uses: actions/setup-node@v1
        with:
          node-version: 14.x
      - name: Prepare JDK 8
        uses: actions/setup-java@v1
        with:
          java-version: 8
      - name: Install Clojure CLI
        run: |
          curl -O https://download.clojure.org/install/linux-install-1.10.1.708.sh &&
          sudo bash ./linux-install-1.10.1.708.sh
      - name: Check versions
        run: |
          echo "Node.js `node --version`"
          echo "yarn `yarn --version`"
          java -version
          echo "Clojure `clojure -e "(println (clojure-version))"`"

      - name: Get yarn cache
        uses: actions/cache@v2
        with:
          path: ~/.cache/yarn
          key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}