Skip to content

Commit

Permalink
ci(build-main): separate packages and showcase+starter build in GitHu…
Browse files Browse the repository at this point in the history
…b Actions
  • Loading branch information
SuperITMan committed May 21, 2021
1 parent 7eea6f1 commit 7b1aa25
Show file tree
Hide file tree
Showing 7 changed files with 327 additions and 46 deletions.
79 changes: 56 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
build-and-test:
name: Build and test on Node.js ${{ matrix.node_version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
if: github.actor != 'dependabot[bot]' || startsWith(github.ref_head, 'dependabot/npm_and_yarn/showcase')
|| startsWith(github.ref_head, 'dependabot/npm_and_yarn/starter')
strategy:
matrix:
node_version: ["10", "12"]
Expand All @@ -42,6 +44,9 @@ jobs:
# See: https://github.com/marketplace/actions/checkout
- uses: actions/checkout@v2
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo

# See: https://github.com/marketplace/actions/setup-node-js-environment
- name: Use Node.js ${{ matrix.node_version }}
Expand Down Expand Up @@ -77,6 +82,8 @@ jobs:
echo "Commit SHA : ${GITHUB_SHA}"
echo "Tag name : ${{ env.GH_ACTIONS_TAG }}"
echo "Reference : ${GITHUB_REF}"
echo "Head branch : ${GITHUB_HEAD_REF}"
echo "Base branch : ${GITHUB_BASE_REF}"
echo "Build number: ${GITHUB_RUN_NUMBER}"
echo "Repository : ${GITHUB_REPOSITORY}"
echo "Event : ${GITHUB_EVENT_NAME}"
Expand All @@ -93,27 +100,17 @@ jobs:
mkdir -p ${{ env.LOGS_DIR }}
touch ${{ env.LOGS_FILE }}
- name: Sync packages dependencies when Dependabot bumps dependenciess
run: |
git config user.name "NBB Bot"
git config user.email "[email protected]"
npm run sync:packages-dependencies
git push
if: github.actor == 'dependabot[bot]'

- name: Install dependencies
run: |
npm ci
npm run install:ci:all
run: npm ci

- name: Linting
run: npm run lint:all
- name: Build packages
run: npm run build:trace

- name: Testing
run: npm run test:ci:all
- name: Linting packages
run: npm run lint:packages

- name: "Build showcase:ghpages"
run: npm run build:showcase:ghpages
- name: Testing packages
run: npm run test:ci:packages

# See: https://github.com/marketplace/actions/upload-artifact
- name: Upload stark packages-dist folder
Expand All @@ -123,6 +120,46 @@ jobs:
path: dist/packages-dist
if: env.IS_MAIN_ENVIRONMENT == 1

- name: Generate docs coverage
run: npm run docs:coverage:packages
if: env.IS_MAIN_ENVIRONMENT == 1

- name: Combine coveralls reports
run: node combine-packages-coverage.js
if: env.IS_MAIN_ENVIRONMENT == 1

- name: Clean root node_modules
run: rm -rf ./node_modules

- name: Install starter
run: npm i
working-directory: starter

- name: "Install showcase with install command"
if: github.actor == 'nbb-bot' && startsWith(github.ref_head, 'dependabot/npm_and_yarn')
run: |
rm package-lock.json
npm install
working-directory: showcase

- name: "Install showcase with ci command"
if: github.actor != 'nbb-bot' || !startsWith(github.ref_head, 'dependabot/npm_and_yarn')
run: npm ci
working-directory: showcase

- name: Linting showcase & starter
run: |
npm run lint:showcase
npm run lint:starter
- name: Testing showcase & starter
run: |
npm run test:ci:showcase
npm run test:ci:starter
- name: "Build showcase:ghpages"
run: npm run build:showcase:ghpages

# See: https://github.com/marketplace/actions/upload-artifact
- name: Upload showcase dist folder
uses: actions/upload-artifact@v2
Expand Down Expand Up @@ -163,17 +200,13 @@ jobs:
local-testing: stop
if: env.IS_MAIN_ENVIRONMENT == 1 && github.event_name == 'push'

- name: Generate docs coverage
run: npm run docs:coverage
- name: Generate starter docs coverage
run: npm run docs:starter:coverage
if: env.IS_MAIN_ENVIRONMENT == 1

- name: Save logs
run: bash ./scripts/ci/print-logs.sh

- name: Combine coveralls reports
run: node combine-packages-coverage.js
if: env.IS_MAIN_ENVIRONMENT == 1

- name: Coveralls
uses: coverallsapp/github-action@master
with:
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/dependabot-pr-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Dependabot Pull Request check

on:
pull_request:

env:
TZ: "Europe/Brussels"

jobs:
check-if-dependabot-root-pr:
name: Check PR has been opened by Dependabot for a root dependency
if: github.actor == 'dependabot[bot]' && !startsWith(github.head_ref, 'dependabot/npm_and_yarn/showcase') && !startsWith(github.head_ref, 'dependabot/npm_and_yarn/starter')
runs-on: ubuntu-latest
steps:
- name: List main variables
run: |
echo "Commit SHA : ${GITHUB_SHA}"
echo "Reference : ${GITHUB_REF}"
echo "Head branch : ${GITHUB_HEAD_REF}"
echo "Base branch : ${GITHUB_BASE_REF}"
echo "Build number: ${GITHUB_RUN_NUMBER}"
echo "Repository : ${GITHUB_REPOSITORY}"
echo "Event : ${GITHUB_EVENT_NAME}"
echo "Author : ${GITHUB_ACTOR}"
64 changes: 64 additions & 0 deletions .github/workflows/dependabot-sync-stark-dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Dependabot - Sync stark-* packages dependencies versions

on:
workflow_run:
workflows: ["Dependabot Pull Request check"]
types:
- completed
env:
TZ: "Europe/Brussels"
NPM_VERSION: "latest-6"

jobs:
run_checks:
runs-on: "ubuntu-latest"
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
&& github.actor == 'dependabot[bot]'
env:
PR_NUMBER: "${{ github.event.workflow_run.pull_requests[0].number }}"
name: "Sync Stark-* dependencies versions for Dependabot PR #${{ github.event.workflow_run.pull_requests[0].number }}"
steps:
# See: https://github.com/marketplace/actions/setup-node-js-environment
- name: Use Node.js 10
uses: actions/setup-node@v2
with:
node-version: 10

- name: Install npm ${{ env.NPM_VERSION }}
run: npm i -g npm@${{ env.NPM_VERSION }}

- name: List main variables
run: |
echo "Commit SHA : ${GITHUB_SHA}"
echo "Reference : ${GITHUB_REF}"
echo "Head branch : ${GITHUB_HEAD_REF}"
echo "Base branch : ${GITHUB_BASE_REF}"
echo "Build number: ${GITHUB_RUN_NUMBER}"
echo "Repository : ${GITHUB_REPOSITORY}"
echo "Event : ${GITHUB_EVENT_NAME}"
echo "Author : ${GITHUB_ACTOR}"
echo "PR Number : ${PR_NUMBER}"
# See: https://github.com/marketplace/actions/checkout
- uses: actions/checkout@v2
with:
token: ${{ secrets.BOT_TOKEN }}
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo

- name: Configure git user info
run: |
git config --local user.name "NBB Bot"
git config --local user.email "[email protected]"
- name: Sync stark packages dependendencies
run: |
echo "Sync packages dependencies when based on Dependabot update for PR ${PR_NUMBER}: $(_jq '.title')"
npm run sync:packages-dependencies
git push
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ secrets.BOT_TOKEN }}" \
--data '{"body": "Dependency has been updated in stark-* packages dependencies. You should wait for green result before merging this! :+1:"}' \
"https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments"
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.git/
.github/
.idea/
.vscode/
dist/
Expand Down
163 changes: 163 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7b1aa25

Please sign in to comment.