xref: /expo/.github/workflows/sdk.yml (revision ab22f034)
1name: SDK
2
3on:
4  workflow_dispatch:
5    inputs:
6      checkAll:
7        description: 'type "check-all" to force checking all packages'
8        required: false
9        default: ''
10  push:
11    branches: [master, 'sdk-*']
12    paths:
13      - .github/workflows/sdk.yml
14      - tools/**
15      - packages/**
16      - yarn.lock
17  pull_request:
18    paths:
19      - .github/workflows/sdk.yml
20      - tools/**
21      - packages/**
22      - yarn.lock
23  schedule:
24    - cron: 0 14 * * *
25
26concurrency:
27  group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
28  cancel-in-progress: true
29
30jobs:
31  check-packages:
32    runs-on: ubuntu-18.04
33    steps:
34      - name: �� Checkout a ref for the event
35        uses: actions/checkout@v2
36        with:
37          fetch-depth: 100
38      - name: ⬇️ Fetch commits from base branch
39        run: git fetch origin ${{ github.event.before || github.base_ref || 'master' }}:${{ github.event.before || github.base_ref || 'master' }} --depth 100
40        if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
41      - name: ♻️ Restore workspace node modules
42        uses: actions/cache@v2
43        id: node-modules-cache
44        with:
45          path: |
46            # See "workspaces" → "packages" in the root package.json for the source of truth of
47            # which node_modules are affected by the root yarn.lock
48            node_modules
49            apps/*/node_modules
50            home/node_modules
51            packages/*/node_modules
52            packages/@unimodules/*/node_modules
53            react-native-lab/react-native/node_modules
54          key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
55      - name: �� Install node modules in root dir
56        # if: steps.node-modules-cache.outputs.cache-hit != 'true'
57        run: yarn install --frozen-lockfile
58      - name: ♻️ Restore node modules in tools
59        uses: actions/cache@v2
60        with:
61          path: tools/node_modules
62          key: ${{ runner.os }}-modules-${{ hashFiles('tools/yarn.lock') }}
63      - name: �� Check packages
64        run: |
65          echo "Checking packages according to the event name: ${{ github.event_name }}"
66          if [[ "${{ github.event_name }}" == "schedule" || "${{ github.event.inputs.checkAll }}" == "check-all" ]]; then
67            # Check all packages on scheduled events or if requested by workflow_dispatch event.
68            bin/expotools check-packages --all
69          else
70            # On push event check packages changed since previous remote head.
71            # In pull requests and workflow_dispatch events check all packages changed in the entire PR.
72            bin/expotools check-packages --since ${{ github.event.before || github.base_ref || 'master' }}
73          fi
74      - name: �� Notify on Slack
75        uses: 8398a7/action-slack@v3
76        if: failure() && (github.event.ref == 'refs/heads/master' || startsWith(github.event.ref, 'refs/heads/sdk-'))
77        env:
78          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79          SLACK_WEBHOOK_URL: ${{ secrets.slack_webhook_api }}
80        with:
81          channel: '#api'
82          status: ${{ job.status }}
83          fields: job,message,ref,eventName,author,took
84          author_name: Check packages
85