Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade node version to v18-20 and yarn to v3 #600

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8440ceb
updating .yarnrc.yml file so its the same as module-template
georgewrmarshall Jan 30, 2024
4be93e4
upgrading @lavamoat/allow-scripts to v3
georgewrmarshall Jan 30, 2024
be3a5bc
upgrading typescript version and adding related dependencies
georgewrmarshall Jan 30, 2024
3013b67
removing tsup from dependencies to dev dependencies
georgewrmarshall Jan 30, 2024
b29cffe
updating linting scripts to align with module-template
georgewrmarshall Jan 30, 2024
474748b
upgrading more dependencies to align with module-template
georgewrmarshall Jan 30, 2024
e66dac8
updating .nvmrc to align with module-template
georgewrmarshall Jan 30, 2024
27030c5
removing yarn setup
georgewrmarshall Jan 30, 2024
928dcb3
adding all workflows from module-template
georgewrmarshall Jan 30, 2024
6927bc2
updating storybook build script name
georgewrmarshall Jan 30, 2024
d5cd491
fixing incorrect action name
georgewrmarshall Jan 30, 2024
478abc2
adding missing dependency
georgewrmarshall Jan 30, 2024
a7b1502
removing publish docs from workflows
georgewrmarshall Jan 30, 2024
405e1e5
ignoring linting for docs folder for now
georgewrmarshall Jan 30, 2024
3a63e52
fixing lint errors
georgewrmarshall Jan 30, 2024
69cb4b3
more lint fixes
georgewrmarshall Jan 30, 2024
1708fd1
lint fixes to tests
georgewrmarshall Jan 30, 2024
2583a76
removing yarn setup
georgewrmarshall Jan 30, 2024
d82a223
updating eslintrc ignore files to include docs but exclude css util
georgewrmarshall Jan 31, 2024
adf926e
more additions after using chatGPT to compare package json files
georgewrmarshall Jan 31, 2024
b68ad00
aligning tsconfig with module template
georgewrmarshall Jan 31, 2024
c634a8d
updating allow-scripts
georgewrmarshall Jan 31, 2024
53a1011
removing uneeded storybook and upgrading eslint-plugin-n
georgewrmarshall Jan 31, 2024
96473c6
Removing reference to publish-docs
georgewrmarshall Jan 31, 2024
7e4e97b
updating gitignore to align with yarn 3 and module template
georgewrmarshall Feb 1, 2024
cb1a715
updating changelog with correct linting
georgewrmarshall Feb 1, 2024
6670fa5
Adding more missing files and settings from module-template
georgewrmarshall Feb 1, 2024
cbb2654
updating package.json after lint fix
georgewrmarshall Feb 1, 2024
1371482
attempting to update build and deploy storybook workflow with new act…
georgewrmarshall Feb 1, 2024
07f5c43
adding node-fetch
georgewrmarshall Feb 1, 2024
f8d7d67
adding yarnpkgs which we shouldn't have to do
georgewrmarshall Feb 1, 2024
7b41001
yarn dedupe
georgewrmarshall Feb 1, 2024
4e20e78
updating syntax for node-fetch v3
georgewrmarshall Feb 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- run:
name: Postinstall
command: |
yarn setup
yarn
Copy link
Collaborator Author

@georgewrmarshall georgewrmarshall Jan 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The yarn setup script was previously used in our project as a means to include Lavamoat's allow-scripts. This was necessary at the time due to certain limitations in Lavamoat's developer experience. However, recent improvements in Lavamoat have eliminated these hindrances, particularly when updating dependencies.

"setup": "yarn install && yarn allow-scripts",

As a result, the yarn setup script, which essentially ran yarn install and yarn allow-scripts, has become redundant. Many projects, including ours, are now moving away from using it.

In this pull request, we have removed every instance of the yarn setup script, as shown in the attached screenshot. This change simplifies our scripts and aligns with current best practices

Screenshot 2024-01-30 at 3 39 28 PM

- persist_to_workspace:
root: .
paths:
Expand All @@ -48,7 +48,7 @@ jobs:
at: .
- run:
name: build:storybook
command: yarn build-storybook
command: yarn build:storybook
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yarn build-storybook has been updated to yarn build:storybook to follow the colon format. All instances have been updated

Screenshot 2024-01-30 at 3 40 54 PM

- persist_to_workspace:
root: .
paths:
Expand Down
3 changes: 2 additions & 1 deletion .circleci/scripts/metamaskbot-build-announce.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/usr/bin/env node
const fetch = require('node-fetch');

start().catch((error) => {
console.error(error);
process.exit(1);
});

async function start() {
const fetch = (await import('node-fetch')).default;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-01-31 at 6 13 54 PM

const {
GITHUB_COMMENT_TOKEN,
CIRCLE_PULL_REQUEST,
Expand Down
20 changes: 20 additions & 0 deletions .depcheckrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"ignores": [
"@lavamoat/allow-scripts",
"@lavamoat/preinstall-always-fail",
"@metamask/auto-changelog",
"@types/*",
"prettier-plugin-packagejson",
"ts-node",
"@storybook/addon-actions",
"@storybook/react-webpack5",
"babel-loader",
"rimraf",
"sass",
"webpack",
"@yarnpkg/core",
"@yarnpkg/cli",
"clipanion",
"@yarnpkg/fslib"
Comment on lines +15 to +18
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @mcmire I'm not sure why buy when I run yarn lint it picks up that the yarnpkg are missing dependencies?

    "@yarnpkg/core",
    "@yarnpkg/cli",
    "clipanion",
    "@yarnpkg/fslib"

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense. All of these dependencies are used by Yarn, and depcheck is unable to see that these are used, since they're never imported anywhere. So this is the right call.

]
}
12 changes: 10 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,30 @@ module.exports = {
files: ['*.ts'],
extends: ['@metamask/eslint-config-typescript'],
},

{
files: ['*.js'],
parserOptions: {
sourceType: 'script',
},
extends: ['@metamask/eslint-config-nodejs'],
},

{
files: ['*.test.ts', '*.test.js'],
extends: ['@metamask/eslint-config-jest'],
extends: [
'@metamask/eslint-config-jest',
'@metamask/eslint-config-nodejs',
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

],
},
],

ignorePatterns: [
'!.eslintrc.js',
'!.prettierrc.js',
'dist/',
'storybook-static/',
'.yarn/',
'storybook-static',
'docs/utils/getCSSVariablesFromStylesheet.ts', // TODO: Fix the types in this file
Comment on lines +31 to +33
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

],
};
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
* text=auto

yarn.lock linguist-generated=false

# yarn v3
# See: https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
/.yarn/releases/** binary
/.yarn/plugins/** binary
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


version: 2
updates:
Expand Down
34 changes: 18 additions & 16 deletions .github/workflows/build-deploy-storybook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,24 @@ jobs:
permissions:
contents: write
runs-on: ubuntu-latest
environment: github-pages
steps:
- uses: actions/checkout@v2
- name: Checkout the repository
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
# We check out the pull request's base branch, which will be
# used as the base branch for all git operations.
ref: ${{ github.event.pull_request.base.ref }}
- name: Get Node.js version
id: nvm
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
- uses: actions/setup-node@v2
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Install npm dependencies
run: yarn --immutable
- name: Run build script
run: yarn build:storybook
- name: Deploy to `storybook-static` directory of `gh-pages` branch
uses: peaceiris/actions-gh-pages@de7ea6f8efb354206b205ef54722213d99067935
with:
node-version: ${{ steps.nvm.outputs.NODE_VERSION }}
- run: yarn
- uses: MetaMask/action-publish-gh-pages@v2
with:
build-command: build-storybook
source-directory: storybook-static
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# This `PUBLISH_DOCS_TOKEN` needs to be manually set per-repository.
# Look in the repository settings under "Environments", and set this token in the `github-pages` environment.
personal_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./storybook-static
destination_dir: storybook-static
119 changes: 119 additions & 0 deletions .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Build, Lint, and Test

on:
workflow_call:

jobs:
prepare:
name: Prepare
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Install Yarn dependencies
run: yarn --immutable

build:
name: Build
runs-on: ubuntu-latest
needs:
- prepare
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- run: yarn --immutable --immutable-cache
- run: yarn build
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi

lint:
name: Lint
runs-on: ubuntu-latest
needs:
- prepare
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- run: yarn --immutable --immutable-cache
- run: yarn lint
- name: Validate RC changelog
if: ${{ startsWith(github.head_ref, 'release/') }}
run: yarn lint:changelog --rc
- name: Validate changelog
if: ${{ !startsWith(github.head_ref, 'release/') }}
run: yarn lint:changelog
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi

test:
name: Test
runs-on: ubuntu-latest
needs:
- prepare
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- run: yarn --immutable --immutable-cache
- run: yarn test
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi

compatibility-test:
name: Compatibility test
runs-on: ubuntu-latest
needs:
- prepare
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- run: rm yarn.lock && YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn
- run: yarn test
- name: Require clean working directory
shell: bash
run: |
git restore yarn.lock
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

49 changes: 0 additions & 49 deletions .github/workflows/build-test.yml

This file was deleted.

21 changes: 6 additions & 15 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
default: 'main'
required: true
release-type:
description: 'A SemVer version diff, i.e. major, minor, patch, prerelease etc. Mutually exclusive with "release-version".'
description: 'A SemVer version diff, i.e. major, minor, or patch. Mutually exclusive with "release-version".'
required: false
release-version:
description: 'A specific version to bump to. Mutually exclusive with "release-type".'
Expand All @@ -21,30 +21,21 @@ jobs:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
# This is to guarantee that the most recent tag is fetched.
# This can be configured to a more reasonable value by consumers.
fetch-depth: 0
# We check out the specified branch, which will be used as the base
# branch for all git operations and the release PR.
ref: ${{ github.event.inputs.base-branch }}
- name: Get Node.js version
id: nvm
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
- uses: actions/setup-node@v2
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ steps.nvm.outputs.NODE_VERSION }}
- uses: MetaMask/action-create-release-pr@v1
node-version-file: '.nvmrc'
- uses: MetaMask/action-create-release-pr@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release-type: ${{ github.event.inputs.release-type }}
release-version: ${{ github.event.inputs.release-version }}
artifacts-path: gh-action__release-authors
# Upload the release author artifact for use in subsequent workflows
- uses: actions/upload-artifact@v2
with:
name: release-authors
path: gh-action__release-authors
if-no-files-found: error
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loading
Loading