diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 3b3698bc4f..9cbb44e938 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -14,8 +14,6 @@ Include a high-level summary of the implementation strategy and list important d - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] My changes generate no new warnings -- [ ] New and existing tests pass locally using `yarn test` -- [ ] I ran `yarn docs` and there were no errors when generating the HTML site - [ ] My code follows the style guidelines of this project (e.g.: no ESLint warnings) # Open questions diff --git a/.github/actions/packages/action.yml b/.github/actions/packages/action.yml new file mode 100644 index 0000000000..389a319356 --- /dev/null +++ b/.github/actions/packages/action.yml @@ -0,0 +1,16 @@ +name: Setup +runs: + using: composite + steps: + - name: Restore lerna cache + id: cache + uses: actions/cache@v2 + with: + path: | + node_modules + */*/node_modules + key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} + - if: steps.cache.outputs.cache-hit != 'true' + name: Install packages + run: yarn + shell: bash diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 961330a8ce..5b6f45f7b7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,46 +15,10 @@ jobs: with: # https://github.com/lerna/lerna/issues/1893#issuecomment-770614785 fetch-depth: 0 - - name: Restore lerna cache - uses: actions/cache@v2 - with: - path: | - node_modules - */*/node_modules - key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - - name: Install deps - run: yarn + - name: Install packages + uses: ./.github/actions/packages - name: Run all builds run: yarn build - - name: Run all tests - run: yarn test - - name: Make test report dir - run: mkdir -p reports/junit - working-directory: packages/core - - name: Run core tests and generate test data - run: yarn coverage --ci --runInBand --reporters=default --reporters=jest-junit - working-directory: packages/core - - name: Move test report - run: mv junit.xml reports/junit/ - working-directory: packages/core - - name: Upload test coverage to codecov - run: bash <(curl -s https://codecov.io/bash) - working-directory: packages/core - # TODO: some equivalent of CircleCI's store_test_results - # with path: packages/core/reports/junit/ - - name: Upload all working example diagrams generated by the test suite - uses: actions/upload-artifact@v2 - with: - name: diagrams - path: /tmp/diagrams/ - - uses: actions/upload-artifact@v2 - with: - name: junit - path: packages/core/reports/junit/ - - uses: actions/upload-artifact@v2 - with: - name: coverage - path: packages/core/coverage - if: github.event_name == 'push' && github.ref == 'refs/heads/main' name: Authenticate with registry run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc @@ -66,28 +30,21 @@ jobs: storybook: runs-on: ubuntu-latest - if: github.event_name == 'push' && github.ref == 'refs/heads/main' defaults: run: working-directory: ./packages/components steps: - name: Checkout uses: actions/checkout@v2 - - name: Restore lerna cache - uses: actions/cache@v2 - with: - path: | - node_modules - */*/node_modules - key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - name: Install packages - run: yarn + uses: ./.github/actions/packages - name: Build core run: yarn build working-directory: ./packages/core - name: Build storybook run: yarn build-storybook - - name: Deploy docs + - if: github.event_name == 'push' && github.ref == 'refs/heads/main' + name: Deploy docs uses: JamesIves/github-pages-deploy-action@4.1.4 with: branch: gh-pages @@ -97,34 +54,72 @@ jobs: run: | mkdir extra touch extra/.nojekyll - - name: Deploy .nojekyll + - if: github.event_name == 'push' && github.ref == 'refs/heads/main' + name: Deploy .nojekyll uses: JamesIves/github-pages-deploy-action@4.1.4 with: branch: gh-pages folder: packages/components/extra clean: false - typedocs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install packages + uses: ./.github/actions/packages + - name: Run all tests + run: yarn test + + test-core: runs-on: ubuntu-latest - if: github.event_name == 'push' && github.ref == 'refs/heads/main' defaults: run: working-directory: ./packages/core steps: - name: Checkout uses: actions/checkout@v2 - - name: Restore lerna cache - uses: actions/cache@v2 + - name: Install packages + uses: ./.github/actions/packages + - name: Make test report dir + run: mkdir -p reports/junit + - name: Run core tests and generate test data + run: yarn coverage --ci --runInBand --reporters=default --reporters=jest-junit + - name: Move test report + run: mv junit.xml reports/junit/ + - name: Upload test coverage to codecov + run: bash <(curl -s https://codecov.io/bash) + # TODO: some equivalent of CircleCI's store_test_results + # with path: packages/core/reports/junit/ + - name: Upload all working example diagrams generated by the test suite + uses: actions/upload-artifact@v2 + with: + name: diagrams + path: /tmp/diagrams/ + - uses: actions/upload-artifact@v2 + with: + name: junit + path: packages/core/reports/junit/ + - uses: actions/upload-artifact@v2 with: - path: | - node_modules - */*/node_modules - key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} + name: coverage + path: packages/core/coverage + + typedocs: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./packages/core + steps: + - name: Checkout + uses: actions/checkout@v2 - name: Install packages - run: yarn + uses: ./.github/actions/packages - name: Build docs run: yarn docs - - name: Deploy docs + - if: github.event_name == 'push' && github.ref == 'refs/heads/main' + name: Deploy docs uses: JamesIves/github-pages-deploy-action@4.1.4 with: branch: gh-pages @@ -134,7 +129,8 @@ jobs: run: | mkdir extra touch extra/.nojekyll - - name: Deploy .nojekyll + - if: github.event_name == 'push' && github.ref == 'refs/heads/main' + name: Deploy .nojekyll uses: JamesIves/github-pages-deploy-action@4.1.4 with: branch: gh-pages