|
| 1 | +name: Workflow |
| 2 | +on: push |
| 3 | + |
| 4 | +concurrency: |
| 5 | + group: |
| 6 | + "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || |
| 7 | + github.ref }}" |
| 8 | + cancel-in-progress: true |
| 9 | + |
| 10 | +defaults: |
| 11 | + run: |
| 12 | + shell: sh |
| 13 | + |
| 14 | +jobs: |
| 15 | + prepare-environment: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + name: Prepare environment |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v3 |
| 21 | + - uses: actions/setup-node@v3 |
| 22 | + with: |
| 23 | + node-version: "18" |
| 24 | + cache: "yarn" |
| 25 | + cache-dependency-path: yarn.lock |
| 26 | + env: |
| 27 | + FORCE_COLOR: 0 |
| 28 | + - name: Install node_modules on cache miss |
| 29 | + if: steps.cache-node-modules.outputs.cache-hit != 'true' |
| 30 | + run: yarn install --frozen-lockfile |
| 31 | + - name: Cache node_modules |
| 32 | + if: steps.cache-node-modules.outputs.cache-hit != 'true' |
| 33 | + uses: actions/cache/save@v3 |
| 34 | + with: |
| 35 | + path: node_modules |
| 36 | + key: yarn-${{ hashFiles('yarn.lock') }} |
| 37 | + |
| 38 | + tests: |
| 39 | + name: Run tests |
| 40 | + runs-on: ubuntu-latest |
| 41 | + needs: prepare-environment |
| 42 | + # Tests timeout after 40 minutes |
| 43 | + timeout-minutes: 40 |
| 44 | + permissions: |
| 45 | + contents: read |
| 46 | + steps: |
| 47 | + - name: Checkout |
| 48 | + uses: actions/checkout@v3 |
| 49 | + - name: Set up Node.js |
| 50 | + uses: actions/setup-node@v3 |
| 51 | + with: |
| 52 | + node-version: "18" |
| 53 | + cache: "yarn" |
| 54 | + cache-dependency-path: yarn.lock |
| 55 | + - name: Restore node_modules |
| 56 | + uses: actions/cache/restore@v3 |
| 57 | + id: cache-node-modules |
| 58 | + with: |
| 59 | + path: node_modules |
| 60 | + key: yarn-${{ hashFiles('yarn.lock') }} |
| 61 | + fail-on-cache-miss: false |
| 62 | + - name: Install node_modules on cache miss |
| 63 | + if: steps.cache-node-modules.outputs.cache-hit != 'true' |
| 64 | + run: yarn install --frozen-lockfile |
| 65 | + - name: Build |
| 66 | + run: yarn build |
| 67 | + - name: Lint |
| 68 | + run: yarn lint |
| 69 | + - name: Clear Jest |
| 70 | + run: yarn jest --clearCache |
| 71 | + - name: Test |
| 72 | + run: yarn test --coverage |
| 73 | + # - name: Send Report |
| 74 | + # uses: paambaati/[email protected] |
| 75 | + # env: |
| 76 | + # CC_TEST_REPORTER_ID: c206a2ed5aa86c7480a13634e91e440a27a98a5d134653f8ea9a7d5f987e68c3 |
| 77 | + # with: |
| 78 | + # coverageLocations: | |
| 79 | + # ${{github.workspace}}/packages/core/coverage/lcov.info:lcov |
| 80 | + # ${{github.workspace}}/packages/react/coverage/lcov.info:lcov |
| 81 | + |
| 82 | + release: |
| 83 | + name: Release |
| 84 | + if: ${{ github.ref == 'refs/heads/main' }} |
| 85 | + runs-on: ubuntu-latest |
| 86 | + needs: tests |
| 87 | + steps: |
| 88 | + - name: Checkout |
| 89 | + uses: actions/checkout@v3 |
| 90 | + - name: Set up Node.js |
| 91 | + uses: actions/setup-node@v3 |
| 92 | + with: |
| 93 | + node-version: "18" |
| 94 | + cache: "yarn" |
| 95 | + cache-dependency-path: yarn.lock |
| 96 | + - name: Restore node_modules |
| 97 | + uses: actions/cache/restore@v3 |
| 98 | + id: cache-node-modules |
| 99 | + with: |
| 100 | + path: node_modules |
| 101 | + key: yarn-${{ hashFiles('yarn.lock') }} |
| 102 | + fail-on-cache-miss: false |
| 103 | + - name: Install node_modules on cache miss |
| 104 | + if: steps.cache-node-modules.outputs.cache-hit != 'true' |
| 105 | + run: yarn install --frozen-lockfile |
| 106 | + - name: Build |
| 107 | + run: yarn build |
| 108 | + - name: Publish |
| 109 | + run: yarn release |
| 110 | + env: |
| 111 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 112 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments