From 992debb694dc65eda7a89a6719d4f9a7b7c7d99f Mon Sep 17 00:00:00 2001 From: chengda300 <97393284+chengda300@users.noreply.github.com> Date: Tue, 8 Apr 2025 01:36:44 +0800 Subject: [PATCH 1/7] Create node.js.yml Create workflow for nodejs --- .github/workflows/node.js.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/node.js.yml diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..2284b93 --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,31 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs + +name: Node.js CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18.x, 20.x, 22.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm run build --if-present + - run: npm test From 06cbc7326b694e492d3a710fec064af2caa875f8 Mon Sep 17 00:00:00 2001 From: chengda300 <97393284+chengda300@users.noreply.github.com> Date: Tue, 8 Apr 2025 01:38:00 +0800 Subject: [PATCH 2/7] Update node.js.yml Change npm to yarn --- .github/workflows/node.js.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 2284b93..61a080b 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -25,7 +25,7 @@ jobs: uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - cache: 'npm' - - run: npm ci - - run: npm run build --if-present - - run: npm test + cache: yarn + - run: yarn ci + - run: yarn run build --if-present + - run: yarn test From 740903fea63b484e7bf7c425e0b8985ff6afb711 Mon Sep 17 00:00:00 2001 From: chengda300 <97393284+chengda300@users.noreply.github.com> Date: Tue, 8 Apr 2025 01:38:53 +0800 Subject: [PATCH 3/7] Update node.js.yml --- .github/workflows/node.js.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 61a080b..db7fcba 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -26,6 +26,6 @@ jobs: with: node-version: ${{ matrix.node-version }} cache: yarn - - run: yarn ci + - run: yarn format:ci - run: yarn run build --if-present - run: yarn test From 8ff3f64ba3e5849a2490e3590d9f55c8487392f8 Mon Sep 17 00:00:00 2001 From: chengda300 <97393284+chengda300@users.noreply.github.com> Date: Tue, 8 Apr 2025 01:40:48 +0800 Subject: [PATCH 4/7] Update node.js.yml --- .github/workflows/node.js.yml | 57 +++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 16 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index db7fcba..0c1e52d 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -1,31 +1,56 @@ -# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs +# This file is copied from https://github.com/source-academy/js-slang/blob/master/.github/workflows/nodejs.yml +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions name: Node.js CI on: push: - branches: [ "main" ] + branches: + - master pull_request: - branches: [ "main" ] + branches: + - master jobs: build: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [18.x, 20.x, 22.x] - # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ - steps: - - uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node-version }} + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Check for package-lock.json + run: | + if [ -e package-lock.json ]; then + echo "package-lock.json found; please do not use NPM! This project uses Yarn!" + exit 1 + fi + exit 0 + - name: Install dependencies (apt) + run: | + sudo apt-get update && \ + sudo apt-get install -y --no-install-recommends \ + texlive texlive-fonts-extra texlive-lang-cjk latexmk latex-cjk-all + # Has to be run before actions/setup-node. + # See: https://github.com/actions/setup-node/issues/480 + - name: Enable corepack for Yarn + run: corepack enable + - name: Setup Node uses: actions/setup-node@v4 with: - node-version: ${{ matrix.node-version }} + node-version: 20 cache: yarn + - run: yarn install --immutable + - run: yarn build - run: yarn format:ci - - run: yarn run build --if-present - - run: yarn test + - run: yarn eslint + - run: yarn test-coverage + env: + CI: true + - name: Check that docs build + run: yarn jsdoc prepare + - name: Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} From 2ba372a275ea91b5d52aefb37d9eab47f8f473ae Mon Sep 17 00:00:00 2001 From: chengda300 <97393284+chengda300@users.noreply.github.com> Date: Tue, 8 Apr 2025 01:43:56 +0800 Subject: [PATCH 5/7] Update node.js.yml --- .github/workflows/node.js.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 0c1e52d..88456a6 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -16,10 +16,6 @@ jobs: build: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - submodules: recursive - name: Check for package-lock.json run: | if [ -e package-lock.json ]; then @@ -48,9 +44,3 @@ jobs: - run: yarn test-coverage env: CI: true - - name: Check that docs build - run: yarn jsdoc prepare - - name: Coveralls - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.GITHUB_TOKEN }} From 9986dfc8e43ecbfadf78e3a2aa24f1e694c96244 Mon Sep 17 00:00:00 2001 From: chengda300 <97393284+chengda300@users.noreply.github.com> Date: Tue, 8 Apr 2025 01:47:41 +0800 Subject: [PATCH 6/7] Update node.js.yml --- .github/workflows/node.js.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 88456a6..741cc9f 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -7,14 +7,20 @@ name: Node.js CI on: push: branches: - - master + [ "main" ] pull_request: branches: - - master + [ "main" ] jobs: build: runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18.x, 20.x, 22.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + steps: - name: Check for package-lock.json run: | @@ -32,10 +38,10 @@ jobs: # See: https://github.com/actions/setup-node/issues/480 - name: Enable corepack for Yarn run: corepack enable - - name: Setup Node + - name: Setup Node ${{ matrix.node-version }} uses: actions/setup-node@v4 with: - node-version: 20 + node-version: ${{ matrix.node-version }} cache: yarn - run: yarn install --immutable - run: yarn build From ede87faeefa307982bfed3c5a35a4b2c777f0522 Mon Sep 17 00:00:00 2001 From: chengda300 <97393284+chengda300@users.noreply.github.com> Date: Tue, 8 Apr 2025 01:54:14 +0800 Subject: [PATCH 7/7] Update node.js.yml --- .github/workflows/node.js.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 741cc9f..cb5e5e0 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -22,6 +22,10 @@ jobs: # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive - name: Check for package-lock.json run: | if [ -e package-lock.json ]; then