Skip to content

Commit

Permalink
ci: Setup for v2 branch
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrzesik committed Feb 22, 2022
1 parent 9b17e8d commit e32af9b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 35 deletions.
14 changes: 2 additions & 12 deletions .github/workflows/integrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ name: Integrate

on:
push:
branches: [master]
branches: [v2]

env:
SLS_IGNORE_WARNING: '*'
FORCE_COLOR: 1

jobs:
linuxNode16:
name: '[Linux] Node.js 16: Publish canary, Unit & packaging tests '
name: '[Linux] Node.js 16: Unit & packaging tests '
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand All @@ -24,16 +24,6 @@ jobs:
node-version: 16.x
registry-url: https://registry.npmjs.org

- name: Publish canary
# Note: Setting NODE_AUTH_TOKEN as job|workspace wide env var won't work
# as it appears actions/setup-node sets own value
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # 01dd......71cc
run: |
./.github/prepare-canary.js
npm publish --tag canary
git checkout .
- name: Retrieve dependencies from cache
id: cacheNpm
uses: actions/cache@v2
Expand Down
21 changes: 12 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:

- name: Retrieve dependencies from cache
uses: actions/cache@v2
id: cacheNpm
with:
path: |
~/.npm
Expand Down Expand Up @@ -64,21 +65,19 @@ jobs:

- name: Retrieve dependencies from cache
uses: actions/cache@v2
id: cacheNpm
with:
path: |
~/.npm
node_modules
key: npm-v16-${{ runner.os }}-refs/heads/master-${{ hashFiles('package.json') }}
key: npm-v16-${{ runner.os }}-refs/heads/v2-${{ hashFiles('package.json') }}

- name: Install Node.js and npm
uses: actions/setup-node@v1
with:
node-version: 16.x
registry-url: https://registry.npmjs.org

# Normally we have a guarantee that deps are already there, still it may not be the case when:
# - `master` build for same commit failed (and we still pushed tag manually)
# - We've pushed tag manually before `master` build finalized
- name: Install dependencies
if: steps.cacheNpm.outputs.cache-hit != 'true'
run: |
Expand All @@ -90,7 +89,7 @@ jobs:
# as it appears actions/setup-node sets own value
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish
run: npm publish --tag latest-2

- name: Build standalone artifacts
run: npm run pkg:build
Expand All @@ -108,7 +107,7 @@ jobs:
run: |
TEMP_ARRAY=($(echo $GITHUB_REF | tr "/" "\n"))
TAG=${TEMP_ARRAY[@]: -1}
npm run pkg:upload -- $TAG
npm run pkg:upload -- $TAG --legacy
chocoPublish:
name: Publish to Chocolatey
Expand All @@ -122,20 +121,24 @@ jobs:

- name: Retrieve dependencies from cache
uses: actions/cache@v2
id: cacheNpm
with:
path: |
~/.npm
node_modules
key: npm-v16-${{ runner.os }}-refs/heads/master-${{ hashFiles('package.json') }}
key: npm-v16-${{ runner.os }}-refs/heads/v2-${{ hashFiles('package.json') }}

- name: Install Node.js and npm
uses: actions/setup-node@v1
with:
node-version: 16.x
registry-url: https://registry.npmjs.org

# Note: No need to install dependencies as we have retrieved cached `node_modules` for very
# same `package.json` as stored with recent `master `build
- name: Install dependencies
if: steps.cacheNpm.outputs.cache-hit != 'true'
run: |
npm update --no-save
npm update --save-dev --no-save
- name: Publish to Chocolatey
shell: bash
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Validate

on:
pull_request:
branches: [master]
branches: [v2]

env:
SLS_IGNORE_WARNING: '*'
Expand All @@ -22,11 +22,11 @@ jobs:
# It's loose and imperfect assumption that PR has no more than 30 commits
fetch-depth: 30

- name: Retrieve last master commit (for `git diff` purposes)
- name: Retrieve last v2 commit (for `git diff` purposes)
run: |
git checkout -b pr
git fetch --prune --depth=30 origin +refs/heads/master:refs/remotes/origin/master
git checkout master
git fetch --prune --depth=30 origin +refs/heads/v2:refs/remotes/origin/v2
git checkout v2
git checkout pr
- name: Retrieve dependencies from cache
Expand All @@ -39,7 +39,7 @@ jobs:
key: npm-v16-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }}
restore-keys: |
npm-v16-${{ runner.os }}-${{ github.ref }}-
npm-v16-${{ runner.os }}-refs/heads/master-
npm-v16-${{ runner.os }}-refs/heads/v2-
- name: Install Node.js and npm
uses: actions/setup-node@v1
Expand All @@ -57,10 +57,10 @@ jobs:
run: npm run lint:updated
- name: Validate commit messages
if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id
run: npx commitlint -f master
run: npx commitlint -f v2
- name: Validate changelog (if new version)
run: |
NEW_VERSION=`git diff -U0 master package.json | grep '"version": "' | tail -n 1 | grep -oE "[0-9]+\.[0-9]+\.[0-9]+"` || :
NEW_VERSION=`git diff -U0 v2 package.json | grep '"version": "' | tail -n 1 | grep -oE "[0-9]+\.[0-9]+\.[0-9]+"` || :
if [ -n "$NEW_VERSION" ];
then
npx dump-release-notes-from-cc-changelog $NEW_VERSION
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
key: npm-v16-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }}
restore-keys: |
npm-v16-${{ runner.os }}-${{ github.ref }}-
npm-v16-${{ runner.os }}-refs/heads/master-
npm-v16-${{ runner.os }}-refs/heads/v2-
- name: Install Node.js and npm
uses: actions/setup-node@v1
Expand Down Expand Up @@ -121,7 +121,7 @@ jobs:
key: npm-v14-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }}
restore-keys: |
npm-v14-${{ runner.os }}-${{ github.ref }}-
npm-v14-${{ runner.os }}-refs/heads/master-
npm-v14-${{ runner.os }}-refs/heads/v2-
- name: Install Node.js and npm
uses: actions/setup-node@v1
Expand Down Expand Up @@ -155,7 +155,7 @@ jobs:
key: npm-v12-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }}
restore-keys: |
npm-v12-${{ runner.os }}-${{ github.ref }}-
npm-v12-${{ runner.os }}-refs/heads/master-
npm-v12-${{ runner.os }}-refs/heads/v2-
- name: Install Node.js and npm
uses: actions/setup-node@v1
Expand Down Expand Up @@ -191,7 +191,7 @@ jobs:
key: npm-v10-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }}
restore-keys: |
npm-v10-${{ runner.os }}-${{ github.ref }}-
npm-v10-${{ runner.os }}-refs/heads/master-
npm-v10-${{ runner.os }}-refs/heads/v2-
- name: Install Node.js and npm
uses: actions/setup-node@v1
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,16 @@
"integration-test-setup": "node ./scripts/test/integration-setup/index.js",
"integration-test-teardown": "node ./scripts/test/integration-teardown.js",
"lint": "eslint .",
"lint:updated": "pipe-git-updated --ext=js -- eslint",
"lint:updated": "pipe-git-updated --ext=js --base=v2 -- eslint",
"pkg:build": "node ./scripts/pkg/build.js",
"pkg:generate-choco-package": "node ./scripts/pkg/generate-choco-package.js",
"pkg:upload": "node ./scripts/pkg/upload/index.js",
"postinstall": "node ./scripts/postinstall.js",
"prepare-release": "standard-version && prettier --write CHANGELOG.md",
"prettier-check": "prettier -c \"**/*.{css,html,js,json,md,yaml,yml}\"",
"prettier-check:updated": "pipe-git-updated --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier -c",
"prettier-check:updated": "pipe-git-updated --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml --base=v2 -- prettier -c",
"prettify": "prettier --write \"**/*.{css,html,js,json,md,yaml,yml}\"",
"prettify:updated": "pipe-git-updated --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier --write",
"prettify:updated": "pipe-git-updated --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml --base=v2 -- prettier --write",
"test": "mocha \"test/unit/**/*.test.js\"",
"test:ci": "npm run prettier-check:updated && npm run lint:updated && npm run test:isolated",
"test:isolated": "mocha-isolated \"test/unit/**/*.test.js\""
Expand Down

0 comments on commit e32af9b

Please sign in to comment.