diff --git a/.github/workflows/api_extractor_check.yaml b/.github/workflows/api_extractor_check.yaml deleted file mode 100644 index 337d306831..0000000000 --- a/.github/workflows/api_extractor_check.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: Check for API changes - -on: [push, pull_request] - -jobs: - api-check: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Use Node.js - uses: actions/setup-node@v1 - with: - node-version: '14.x' - - name: Install dependencies - run: yarn --frozen-lockfile - env: - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true - - name: Run API-Extractor - run: yarn api:check - - name: API-Extractor failure - if: ${{ failure() }} - uses: LouisBrunner/diff-action@v0.1.0 - with: - old: packages/charts/api/charts.api.md - new: packages/charts/tmp/charts.api.md - mode: deletion - tolerance: better diff --git a/.github/workflows/auto_release.yaml b/.github/workflows/auto_release.yaml deleted file mode 100644 index b3d5cd3425..0000000000 --- a/.github/workflows/auto_release.yaml +++ /dev/null @@ -1,40 +0,0 @@ -name: Publish release - -on: - workflow_dispatch: - branches: - - master - -jobs: - release_package: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - with: - persist-credentials: false - - name: Use Node.js - uses: actions/setup-node@v1 - with: - node-version: '14.x' - - name: Install node_modules - uses: bahmutov/npm-install@HEAD - env: - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true - - name: Build check - run: yarn build - - name: Lint check - run: yarn lint - - name: Prettier check - run: yarn prettier:check - - name: TimeZone testing - run: yarn test:tz --ci - - name: Testing - run: yarn test --ci - - name: Release - env: - GH_TOKEN: ${{ secrets.ADMIN_TOKEN_GH }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} - run: yarn semantic-release diff --git a/.github/workflows/cleanup.yaml b/.github/workflows/cleanup.yaml deleted file mode 100644 index e10eb13817..0000000000 --- a/.github/workflows/cleanup.yaml +++ /dev/null @@ -1,21 +0,0 @@ -name: Cleanup - -on: - workflow_run: - workflows: ['Lint checks and build', 'Unit testing', 'Check for API changes'] - types: ['requested'] - -jobs: - cancel-duplicate-workflow-runs: - name: 'Cancel duplicate workflow runs' - runs-on: ubuntu-latest - steps: - - uses: potiuk/cancel-workflow-runs@v4_7 - name: 'Cancel duplicate workflow runs' - with: - cancelMode: duplicates - cancelFutureDuplicates: true - token: ${{ secrets.GITHUB_TOKEN }} - sourceRunId: ${{ github.event.workflow_run.id }} - notifyPRCancel: true - skipEventTypes: '["push", "schedule"]' diff --git a/.github/workflows/deploy_docs.yaml b/.github/workflows/deploy_docs.yaml deleted file mode 100644 index 99144b519a..0000000000 --- a/.github/workflows/deploy_docs.yaml +++ /dev/null @@ -1,32 +0,0 @@ -name: Build and Deploy Storybook - -on: - workflow_dispatch: - branches: - - master - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - steps: - - name: Checkout 🛎️ - uses: actions/checkout@v2 - with: - persist-credentials: false - - name: Use Node.js - uses: actions/setup-node@v1 - with: - node-version: '14.x' - - name: Install node_modules - uses: bahmutov/npm-install@HEAD - env: - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true - - name: Build storybook - run: yarn storybook:build - - name: Deploy 🚀 - uses: JamesIves/github-pages-deploy-action@3.7.1 - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH: gh-pages # The branch the action should deploy to. - FOLDER: .out # The folder the action should deploy. - CLEAN: true # Automatically remove deleted files from the deploy branch diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml deleted file mode 100644 index 433239e54b..0000000000 --- a/.github/workflows/lint.yaml +++ /dev/null @@ -1,24 +0,0 @@ -name: Lint checks and build - -on: [push, pull_request] - -jobs: - build-lint: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Use Node.js - uses: actions/setup-node@v1 - with: - node-version: '14.x' - - name: Install node_modules - uses: bahmutov/npm-install@HEAD - env: - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true - - name: Build check - run: yarn build - - name: Lint check - run: yarn lint - - name: Prettier check - run: yarn prettier:check diff --git a/.github/workflows/pr_checker.yaml b/.github/workflows/pr_checker.yaml new file mode 100644 index 0000000000..90ae5c8bc4 --- /dev/null +++ b/.github/workflows/pr_checker.yaml @@ -0,0 +1,136 @@ +name: 'PR Update Check' + +on: + workflow_dispatch: # Trigger manually until pr push check is done + push: + branches: + - master # whenever master changes + schedule: + - cron: '0 0 * * *' # once a day + +env: + ECH_NODE_VERSION: '14.x' + BASE_COMMIT_LIMIT: 10 + CONTEXT: 'PR Update Check' + +jobs: + fetch: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.save.outputs.json }} + steps: + - name: Fetch GH pulls + id: fetch + uses: octokit/request-action@v2.x + with: + route: GET /repos/{repo}/pulls?state=open + repo: ${{ github.repository }} + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + - name: Store matrix + id: save + uses: nickofthyme/object-remap@v1 + with: + include.*.number: ${{ toJSON(fromJSON(steps.fetch.outputs.data).*.number) }} + include.*.title: ${{ toJSON(fromJSON(steps.fetch.outputs.data).*.title) }} + include.*.head_sha: ${{ toJSON(fromJSON(steps.fetch.outputs.data).*.head.sha) }} + include.*.base_ref: ${{ toJSON(fromJSON(steps.fetch.outputs.data).*.base.ref) }} + include.*.base_sha: ${{ toJSON(fromJSON(steps.fetch.outputs.data).*.base.sha) }} + + base-status-check: + name: "PR #${{ matrix.number }} - ${{ matrix.title }}" + runs-on: ubuntu-latest + needs: fetch + strategy: + matrix: ${{ fromJSON(needs.fetch.outputs.matrix) }} + fail-fast: false + steps: + - name: Set pending status + uses: hkusu/status-create-action@v1 + with: + sha: ${{ matrix.headSha }} + state: pending + target-url: "https://github.com/elastic/elastic-charts/actions/runs/${{ github.run_id }}" + description: "Checking if PR is up-to-date" + context: ${{ env.CONTEXT }} + - name: Git base compare + id: base-compare + uses: octokit/request-action@v2.x + with: + route: GET /repos/{repo}/compare/{basehead} + repo: ${{ github.repository }} + basehead: "${{ matrix.baseRef }}...${{ matrix.baseSha }}" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + - run: echo "${{ fromJSON(steps.base-compare.outputs.data).behind_by }}" + - run: echo "This pr is behind by ${{ fromJSON(steps.base-compare.outputs.data).behind_by }} commits" + - name: Set success status - in sync + if: ${{ fromJSON(steps.base-compare.outputs.data).behind_by == 0 }} + uses: hkusu/status-create-action@v1 + with: + sha: ${{ matrix.headSha }} + state: success + target-url: "https://github.com/elastic/elastic-charts/actions/runs/${{ github.run_id }}" + description: PR is in up-to-date with upstream base + context: ${{ env.CONTEXT }} + - name: Git head compare + id: head-compare + if: ${{ fromJSON(steps.base-compare.outputs.data).behind_by > 0 }} + uses: octokit/request-action@v2.x + with: + route: GET /repos/{repo}/compare/{basehead} + repo: ${{ github.repository }} + basehead: "${{ matrix.baseSha }}...${{ matrix.headSha }}" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + - name: Check files changes + id: files-check + if: ${{ fromJSON(steps.base-compare.outputs.data).behind_by > 0 && fromJSON(steps.base-compare.outputs.data).behind_by <= env.BASE_COMMIT_LIMIT }} + shell: python + # TODO: find a better way to do this, possiblly custom action + run: | + import json + baseFiles = json.loads("""${{ toJSON(fromJSON(steps.base-compare.outputs.data).files.*.filename) }}""") + headFiles = json.loads("""${{ toJSON(fromJSON(steps.head-compare.outputs.data).files.*.filename) }}""") + + # file intersection + files = list(filter(lambda x:x in baseFiles, headFiles)) + + hasStaleScreenshot = False + + for file in files: + if file.startswith('integration/tests/__image_snapshots__/') and '/__diff_output__/' not in file: + hasStaleScreenshot = True; + + print(f"::set-output name=hasStaleScreenshot::{str(hasStaleScreenshot).lower()}") + - name: Print output + run: echo ${{ steps.files-check.outputs.hasStaleScreenshot == 'true' }} + - name: Set failed status - out of sync with stale vrt + if: ${{ fromJSON(steps.base-compare.outputs.data).behind_by > 0 && fromJSON(steps.base-compare.outputs.data).behind_by <= env.BASE_COMMIT_LIMIT && steps.files-check.outputs.hasStaleScreenshot == 'true' }} + uses: hkusu/status-create-action@v1 + with: + sha: ${{ matrix.headSha }} + state: failure + target-url: "https://github.com/elastic/elastic-charts/actions/runs/${{ github.run_id }}" + description: "PR has stale VRT screenshots. Please merge with ${{ matrix.baseRef }}." + context: ${{ env.CONTEXT }} + - name: Set success status - not in sync but no stale vrt + if: ${{ fromJSON(steps.base-compare.outputs.data).behind_by > 0 && fromJSON(steps.base-compare.outputs.data).behind_by <= env.BASE_COMMIT_LIMIT && steps.files-check.outputs.hasStaleScreenshot != 'true' }} + uses: hkusu/status-create-action@v1 + with: + sha: ${{ matrix.headSha }} + state: success + target-url: "https://github.com/elastic/elastic-charts/actions/runs/${{ github.run_id }}" + description: "PR is ${{ fromJSON(steps.base-compare.outputs.data).behind_by }} commits behind with no stale VRT screenshots." + context: ${{ env.CONTEXT }} + - name: Set failed status - exceeds synced limit + if: ${{ fromJSON(steps.base-compare.outputs.data).behind_by > env.BASE_COMMIT_LIMIT }} + uses: hkusu/status-create-action@v1 + with: + sha: ${{ matrix.headSha }} + state: failure + target-url: "https://github.com/elastic/elastic-charts/actions/runs/${{ github.run_id }}" + description: "PR is ${{ fromJSON(steps.base-compare.outputs.data).behind_by }} commits behind. Please merge with ${{ matrix.baseRef }}." + context: ${{ env.CONTEXT }} + + diff --git a/.github/workflows/unit_test.yaml b/.github/workflows/unit_test.yaml deleted file mode 100644 index 3260a4e8da..0000000000 --- a/.github/workflows/unit_test.yaml +++ /dev/null @@ -1,27 +0,0 @@ -name: Unit testing - -on: [push, pull_request] - -jobs: - unit_test: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Use Node.js - uses: actions/setup-node@v1 - with: - node-version: '14.x' - - name: Install node_modules - uses: bahmutov/npm-install@HEAD - env: - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true - - name: TimeZone testing - run: yarn test:tz --ci - - name: Testing - run: yarn test --coverage --ci -# - uses: codecov/codecov-action@v1 -# with: -# flags: unittests # optional -# name: gha # optional -# fail_ci_if_error: false