diff --git a/.github/actions/init-all/action.yml b/.github/actions/init-all/action.yml index dc7cb8f2c..0f37eef2a 100644 --- a/.github/actions/init-all/action.yml +++ b/.github/actions/init-all/action.yml @@ -25,10 +25,9 @@ runs: **/uv.lock ## Set up Node environment - - uses: actions/setup-node@v4 + - uses: ./.github/actions/init-node with: - node-version-file: ${{ inputs.node-version-file }} - cache: 'yarn' + node-version-file: ${{ env.node-version-file }} # We require protoc >= 3.20, but Ubuntu 22.04 - the OS that these Github # Actions are running as of 2023.05.03 - doesn't have recent versions diff --git a/.github/actions/init-node/action.yml b/.github/actions/init-node/action.yml new file mode 100644 index 000000000..af321d738 --- /dev/null +++ b/.github/actions/init-node/action.yml @@ -0,0 +1,38 @@ +name: 'Node Initialization Action' +description: 'Node initialization steps for CI jobs' +inputs: + node-version-file: + description: 'Node version file to setup' + required: true +runs: + using: "composite" + steps: + ## Set up Node environment + - uses: actions/setup-node@v4 + with: + node-version-file: ${{ inputs.node-version-file }} + cache: 'yarn' + + - name: Get Node.js version + id: node-version + run: echo "NODE_VERSION=$(node -v)" >> $GITHUB_ENV + shell: bash + # Include the NodeJS version in the cache key. + # While there are several reasons not to recommend caching `node_modules` (https://github.com/actions/setup-node/issues/304#issuecomment-886241508), + # NodeJS version incompatibility is one of them (https://github.com/actions/setup-node/issues/304#issuecomment-886240594). + # So invalidating the cache based on the NodeJS version is not perfect but + # it makes things safer. + # See also https://github.com/actions/setup-node/issues/406 and https://dev.to/flydiverny/comment/1lk25. + + - uses: actions/cache@v4 + with: + path: '**/node_modules' + key: node_modules-${{ env.NODE_VERSION }}-${{ hashFiles('yarn.lock') }} + + # `yarn install` often takes so long time on in the Windows env. + # https://github.com/yarnpkg/yarn/issues/8242 + - run: yarn config set network-timeout 600000 + shell: bash + + - run: yarn install --frozen-lockfile + shell: bash diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6b0010b9a..5635f5564 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -74,11 +74,11 @@ jobs: - uses: actions/checkout@v4 with: submodules: true - - uses: actions/setup-node@v4 + + - uses: ./.github/actions/init-node with: node-version-file: ${{ env.node-version-file }} - cache: 'yarn' - - run: yarn install --frozen-lockfile + - name: Lint run: | yarn check:eslint @@ -176,11 +176,12 @@ jobs: - uses: actions/checkout@v4 with: submodules: true - - uses: actions/setup-node@v4 + + + - uses: ./.github/actions/init-node with: node-version-file: ${{ env.node-version-file }} - cache: 'yarn' - - run: yarn install --frozen-lockfile + - name: Lint run: | yarn check:eslint @@ -201,11 +202,11 @@ jobs: - uses: actions/checkout@v4 with: submodules: true - - uses: actions/setup-node@v4 + + - uses: ./.github/actions/init-node with: node-version-file: ${{ env.node-version-file }} - cache: 'yarn' - - run: yarn install --frozen-lockfile + - run: make sharing-common working-directory: . # - name: Lint @@ -228,11 +229,11 @@ jobs: - uses: actions/checkout@v4 with: submodules: true - - uses: actions/setup-node@v4 + + - uses: ./.github/actions/init-node with: node-version-file: ${{ env.node-version-file }} - cache: 'yarn' - - run: yarn install --frozen-lockfile + - name: Lint run: | yarn check:eslint @@ -258,12 +259,11 @@ jobs: - uses: actions/checkout@v4 with: submodules: true - - uses: actions/setup-node@v4 + + - uses: ./.github/actions/init-node with: node-version-file: ${{ env.node-version-file }} - cache: 'yarn' - - run: yarn config set network-timeout 600000 # `yarn install` often takes so long time on in the Windows env. - - run: yarn install --frozen-lockfile + - run: make common working-directory: . - name: Lint @@ -488,11 +488,10 @@ jobs: - uses: actions/checkout@v4 with: submodules: recursive - - uses: actions/setup-node@v4 + + - uses: ./.github/actions/init-node with: node-version-file: ${{ env.node-version-file }} - cache: 'yarn' - - run: yarn install --frozen-lockfile - name: Cache node_modules/.cache including Webpack's cache uses: actions/cache@v4 @@ -695,12 +694,11 @@ jobs: - uses: actions/checkout@v4 with: submodules: true - - uses: actions/setup-node@v4 + + - uses: ./.github/actions/init-node with: node-version-file: ${{ env.node-version-file }} - cache: 'yarn' - - run: yarn config set network-timeout 300000 # https://github.com/yarnpkg/yarn/issues/8242 - - run: yarn install --frozen-lockfile + - run: yarn playwright install - run: make common - name: Lint diff --git a/Makefile b/Makefile index 4a11f0c65..42bcf71d5 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ all: init mountable sharing sharing-editor .PHONY: init -init: git_submodules venv node_modules +init: git_submodules venv yarn_install VENV := ./.venv NODE_MODULES := ./node_modules