Skip to content

Commit

Permalink
build: migrate to Yarn v3 (#2913)
Browse files Browse the repository at this point in the history
Co-authored-by: Kristoffer K. <merceyz@users.noreply.github.com>
  • Loading branch information
AlCalzone and merceyz committed Jul 6, 2021
1 parent 1ecd34f commit 9fecd4a
Show file tree
Hide file tree
Showing 43 changed files with 14,872 additions and 10,905 deletions.
4 changes: 2 additions & 2 deletions .github/actions/zwave-js-bot/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ async function publishPr() {

// Bump versions
await exec.exec(
"npx",
"yarn",
`lerna version ${newVersion} --exact --allow-branch * --ignore-scripts --no-commit-hooks --yes`.split(
" ",
),
);

// and release
await exec.exec("npx", [
await exec.exec("yarn", [
"lerna",
"publish",
"from-package",
Expand Down
68 changes: 28 additions & 40 deletions .github/workflows-disabled/approve-workflow-runs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch: {}
schedule:
# every 5 minutes
- cron: '*/5 * * * *'
- cron: '*/5 * * * *'

jobs:
approve-workflows:
Expand All @@ -16,42 +16,30 @@ jobs:
node-version: [14.x] # This should be LTS

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Get Yarn cache directory
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Use Yarn cache
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --prefer-offline --frozen-lockfile

- name: Check and approve workflows
uses: actions/github-script@v3
with:
github-token: ${{secrets.BOT_TOKEN}}
script: |
const bot = require(`${process.env.GITHUB_WORKSPACE}/.github/bot-scripts/index.js`);
const workflows = [
".github/workflows/generate-docs.yml",
".github/workflows/test-and-release.yml",
".github/workflows/codeql-analysis.yml"
];
const whitelist = [
"packages/config/config/**/*.json"
];
return bot.approveWorkflows({github, context, workflows, whitelist});
- name: Checkout code
uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'

- name: Install dependencies
run: yarn install --immutable

- name: Check and approve workflows
uses: actions/github-script@v3
with:
github-token: ${{secrets.BOT_TOKEN}}
script: |
const bot = require(`${process.env.GITHUB_WORKSPACE}/.github/bot-scripts/index.js`);
const workflows = [
".github/workflows/generate-docs.yml",
".github/workflows/test-and-release.yml",
".github/workflows/codeql-analysis.yml"
];
const whitelist = [
"packages/config/config/**/*.json"
];
return bot.approveWorkflows({github, context, workflows, whitelist});
18 changes: 3 additions & 15 deletions .github/workflows/cc-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,13 @@ jobs:
uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Get Yarn cache directory
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Use Yarn cache
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
cache: 'yarn'

- name: Install dependencies
run: yarn install --prefer-offline --frozen-lockfile
run: yarn install --immutable

- name: Compile TypeScript code
run: yarn run build
Expand Down
18 changes: 3 additions & 15 deletions .github/workflows/generate-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,13 @@ jobs:
fetch-depth: 0

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Get Yarn cache directory
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Use Yarn cache
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
cache: 'yarn'

- name: Install dependencies
run: yarn install --prefer-offline --frozen-lockfile
run: yarn install --immutable

- name: Compile TypeScript code
run: yarn run build
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/nightly-config-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ jobs:
fetch-depth: 0 # Fetch the history, or this action won't work

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'

- name: Detect changes (git)
run: |
Expand Down Expand Up @@ -52,15 +53,14 @@ jobs:
# Install dependencies
# ===============================
npm i -g yarn
yarn install --frozen-lockfile
yarn install --immutable
# ===============================
# Double-check changes with lerna
# ===============================
# Verify that only @zwave-js/config and zwave-js are changed
LERNA_CHANGED=$(npx lerna changed)
LERNA_CHANGED=$(yarn lerna changed)
if [[ $(echo -e "@zwave-js/config\nzwave-js") != "$LERNA_CHANGED" ]]; then
echo "❌ Lerna detected unexpected package changes, aborting..."
echo "These packages are changed:"
Expand All @@ -73,7 +73,7 @@ jobs:
# ===============================
# Create a clean build
npx lerna run build
yarn lerna run build
# Lint config files
yarn run lint:config
Expand All @@ -89,7 +89,7 @@ jobs:
# Figure out next version
cat > ./script.js << 'EOF'
const semver = require("semver");
let v = require("../config/package.json").version;
let v = require("@zwave-js/config/package.json").version;
const now = new Date();
const today = new Date(now.getTime() - now.getTimezoneOffset()*60000);
const dateStr = today.toISOString().split("T")[0].replace(/-/g, "");
Expand Down
Loading

0 comments on commit 9fecd4a

Please sign in to comment.