diff --git a/.github/workflows/checkin.yml b/.github/workflows/checkin.yml deleted file mode 100644 index d07bce3..0000000 --- a/.github/workflows/checkin.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: "PR Checks" -on: [pull_request, push] - -concurrency: - # Skip intermediate builds: all builds except for builds on the `master`, `main`, or `release-*` branches - # Cancel intermediate builds: only pull request builds - group: ${{ github.workflow }}-${{ github.ref }}-${{ github.ref != 'refs/heads/master' || github.ref != 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release-') || github.run_number }} - cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} - -jobs: - check_pr: - runs-on: ubuntu-latest - timeout-minutes: 60 - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-node@v4 - with: - node-version-file: '.tool-versions' - - - name: "npm ci" - run: npm ci - - - name: "npm run build" - run: npm run build - - - name: "npm run test" - run: npm run test - - - name: "check for uncommitted changes" - # Ensure no changes, but ignore node_modules dir since dev/fresh ci deps installed. - run: | - git diff --exit-code --stat -- . ':!node_modules' \ - || (echo "##[error] found changed files after build. please 'npm ci && npm run build'" \ - "and check in all changes" \ - && exit 1) diff --git a/.github/workflows/pr_checks.yml b/.github/workflows/pr_checks.yml new file mode 100644 index 0000000..a7582eb --- /dev/null +++ b/.github/workflows/pr_checks.yml @@ -0,0 +1,245 @@ +name: PR Checks +on: + pull_request: + push: + branches: + - master + tags: '*' +concurrency: + # Skip intermediate builds: all builds except for builds on the `master` branch + # Cancel intermediate builds: only pull request builds + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.ref != 'refs/heads/master' || github.run_number }} + cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} +permissions: + contents: read +jobs: + finalize-pr-checks: + if: always() # this line is important to keep the `finalize` job from being marked as skipped; do not change or delete this line + runs-on: ubuntu-latest + timeout-minutes: 10 + needs: [ + checked-in-files, + build, + npm-run-test, + make-targets, + stalecheck-npm-install, + ] + steps: + - run: | + echo checked-in-files: ${{ needs.checked-in-files.result }} + echo build: ${{ needs.build.result }} + echo npm-run-test: ${{ needs.npm-run-test.result }} + echo make-targets: ${{ needs.make-targets.result }} + echo stalecheck-npm-install: ${{ needs.stalecheck-npm-install.result }} + # The last line must NOT end with || + # All other lines MUST end with || + - run: exit 1 + if: | + (needs.checked-in-files.result != 'success') || + (needs.build.result != 'success') || + (needs.npm-run-test.result != 'success') || + (needs.make-targets.result != 'success') || + (needs.stalecheck-npm-install.result != 'success') + checked-in-files: + timeout-minutes: 30 + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + ### Check out the repo: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + with: + persist-credentials: false + ### Cleanall: + - run: make cleanall + ### Install NodeJS + # Unix (non-Windows): + - uses: asdf-vm/actions/setup@05e0d2ed97b598bfce82fd30daf324ae0c4570e6 + if: runner.os != 'Windows' + - run: make unix-asdf-install + if: runner.os != 'Windows' + # Windows: + # Windows does not support asdf, so we have to use `actions/setup-node` + # to install asdf: + - uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b + if: runner.os == 'Windows' + with: + node-version-file: '.tool-versions' + ### Install the NodeJS packages that we depend on: + - run: make install-packages + ### Print some debugging info: + - name: Print the NodeJS version (for debugging) + run: | + which -a node + node --version + which -a npm + npm --version + ### Build: + - run: make pack + ### Clean (not cleanall!): + - run: make clean + ### Make sure there are no uncommited changes + - uses: julia-actions/setup-julia@780022b48dfc0c2c6b94cfee6a9284850107d037 + with: + version: '1' + - run: git --no-pager status + - run: git --no-pager diff + - run: julia ./ci/check_uncommitted_changes.jl + build: + timeout-minutes: 30 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + steps: + ### Check out the repo: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + with: + persist-credentials: false + ### Cleanall: + - run: make cleanall + ### Install NodeJS + # Unix (non-Windows): + - uses: asdf-vm/actions/setup@05e0d2ed97b598bfce82fd30daf324ae0c4570e6 + if: runner.os != 'Windows' + - run: make unix-asdf-install + if: runner.os != 'Windows' + # Windows: + # Windows does not support asdf, so we have to use `actions/setup-node` + # to install asdf: + - uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b + if: runner.os == 'Windows' + with: + node-version-file: '.tool-versions' + ### Install the NodeJS packages that we depend on: + - run: make install-packages + ### Print some debugging info: + - name: Print the NodeJS version (for debugging) + run: | + which -a node + node --version + which -a npm + npm --version + ### Build: + - run: make build + - run: make pack + ### Make sure some other `make` targets don't bitrot: + - name: Run some other `make` targets to ensure that they don't bitrot + run: | + make clean + make cleanall + - name: Run all of the "cleaning" `make` targets to ensure that they don't bitrot + run: | + make clean + make cleanall + npm-run-test: + timeout-minutes: 30 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + steps: + ### Check out the repo: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + with: + persist-credentials: false + ### Cleanall: + - run: make cleanall + ### Install NodeJS + # Unix (non-Windows): + - uses: asdf-vm/actions/setup@05e0d2ed97b598bfce82fd30daf324ae0c4570e6 + if: runner.os != 'Windows' + - run: make unix-asdf-install + if: runner.os != 'Windows' + # Windows: + # Windows does not support asdf, so we have to use `actions/setup-node` + # to install asdf: + - uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b + if: runner.os == 'Windows' + with: + node-version-file: '.tool-versions' + ### Install the NodeJS packages that we depend on: + - run: make install-packages + ### Print some debugging info: + - name: Print the NodeJS version (for debugging) + run: | + which -a node + node --version + which -a npm + npm --version + ### Build: + - run: make build + - run: make test + make-targets: # This is a job to make sure that none of the `make` targets bitrot + timeout-minutes: 30 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + steps: + ### Check out the repo: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + with: + persist-credentials: false + ### Cleanall: + - run: make cleanall + ### Install NodeJS + # Unix (non-Windows): + - uses: asdf-vm/actions/setup@05e0d2ed97b598bfce82fd30daf324ae0c4570e6 + if: runner.os != 'Windows' + - run: make unix-asdf-install + if: runner.os != 'Windows' + ### Install the NodeJS packages that we depend on: + - run: make install-packages + ### Make sure some other `make` targets don't bitrot: + - name: Run some other `make` targets to ensure that they don't bitrot + run: | + make unix-asdf-install + make install-packages + make build + make pack + make everything-from-scratch + - name: Run all of the "cleaning" `make` targets to ensure that they don't bitrot + run: | + make clean + make cleanall + stalecheck-npm-install: + # In this job, we are basically trying to check if `package-lock.json` is in + # sync with `package-lock.json`. + # + # So, for example, if someone manually edits the `package.json` file, we want + # to make sure that the `package-lock.json` file is not out of sync with the + # `package.json` file. + timeout-minutes: 30 + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + ### Check out the repo: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + with: + persist-credentials: false + ### Install NodeJS + # Unix (non-Windows): + - uses: asdf-vm/actions/setup@05e0d2ed97b598bfce82fd30daf324ae0c4570e6 + if: runner.os != 'Windows' + - run: make unix-asdf-install + if: runner.os != 'Windows' + ### Run the master commands for this job: + - run: make clean + - run: npm ci + # - run: npm install --package-lock-only + - run: npm install + ### Make sure there are no uncommited changes + - uses: julia-actions/setup-julia@780022b48dfc0c2c6b94cfee6a9284850107d037 + with: + version: '1' + - run: git --no-pager status + - run: git --no-pager diff + - run: julia ./ci/check_uncommitted_changes.jl diff --git a/.gitignore b/.gitignore index bb7cf0b..692e74b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ node_modules/ __tests__/runner/* -dist/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ff69f83 --- /dev/null +++ b/Makefile @@ -0,0 +1,49 @@ +.NOTPARALLEL: + +# This is the default target: +.PHONY: pack +pack: build + npm run pack + +# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +.PHONY: everything-from-scratch +everything-from-scratch: cleanall install-packages build pack clean + +# build does `npm run build`, but does not run `npm run pack` +.PHONY: build +build: + npm run build + +.PHONY: test +test: + npm run test + +.PHONY: install-packages +install-packages: + rm -rf node_modules/ + # Note: we use `npm ci` instead of `npm install`, because we want to make sure + # that we respect the versions in the `package-lock.json` lockfile. + npm ci + +# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +.PHONY: clean +clean: + rm -rf node_modules/ + +.PHONY: cleanall +cleanall: clean + rm -rf lib/ + rm -rf dist/ + +# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +# asdf does not support Windows. +# On Windows, users need to install the correct version of NodeJS themselves. +.PHONY: unix-asdf-install +unix-asdf-install: + asdf plugin add nodejs # update this list when we add more tools to `.tool-versions` + asdf install + +# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/ci/check_uncommitted_changes.jl b/ci/check_uncommitted_changes.jl new file mode 100644 index 0000000..5c677a8 --- /dev/null +++ b/ci/check_uncommitted_changes.jl @@ -0,0 +1,16 @@ +const cmd = `git --no-pager diff --exit-code --stat` + +const proc = run(pipeline(cmd; stdin, stdout, stderr); wait = false) + +wait(proc) + +@info "" success(proc) proc.exitcode + +if !success(proc) + recommended_cmd = "make everything-from-scratch" + msg = "##[error] found changed files after build. " * + "Please run `$(recommended_cmd)` and " * + "then check in all changes." + println(stderr, msg) + exit(1) +end diff --git a/devdocs/local_setup.md b/devdocs/local_setup.md index 01597b2..20ddbd8 100644 --- a/devdocs/local_setup.md +++ b/devdocs/local_setup.md @@ -42,6 +42,8 @@ First, `cd` to your clone of the repo. Now you can run the following commands: npm ci npm run build + +npm run pack ``` When you are ready, you can commit your changes and push them to your PR. diff --git a/devdocs/making_a_new_release.md b/devdocs/making_a_new_release.md index dc5fd5e..135c6f3 100644 --- a/devdocs/making_a_new_release.md +++ b/devdocs/making_a_new_release.md @@ -1,128 +1,56 @@ # Making a new release of this action (requires commit access) -If you have commit access to this repo, you can make a new release. +In this guide, as an example, `v2.2.0` refers to the version number of the new release that you want to make. -Here are the instructions. +## Part 1: Use the Git CLI to create and push the Git tags -## Step 1: Clone a fresh copy of the repo - -We intentionally work in a brand-new copy of the repo. +Step 1: Create a new lightweight tag of the form `vMAJOR.MINOR.PATCH`. ```bash git clone git@github.com:julia-actions/setup-julia.git cd setup-julia -git checkout master -git submodule init -git submodule update +git fetch --all --tags + +git checkout main + +git --no-pager log -1 +# Take note of the commit hash here. + +# Now, create a new lightweight tag of the form `vMAJOR.MINOR.PATCH`. +# +# Replace `commit_hash` with the commit hash that you obtained from the +# `git log -1` step. +# +# Replace `v2.2.0` with the actual version number that you want to use. +git tag v2.2.0 commit_hash ``` -## Step 2: Make sure you have the right version of NodeJS - -If you use [`asdf`](https://asdf-vm.com/), this is as simple as: +Step 2: Once you've created the new release, you need to update the `v2` tag to point to the new release. For example, suppose that the previous release was `v2.1.0`, and suppose that you just created the new release `v2.2.0`. You need to update the `v2` tag so that it points to `v2.2.0`. Here are the commands: ```bash -asdf plugin add nodejs -asdf install +# Create/update the new v2 tag locally, where the new v2 tag will point to the +# release that you created in the previous step. +# +# Make sure to change `v2.2.0` to the actual value for the tag that you just +# created in the previous step. +# +# The `-f` flag forcibly overwrites the old +# `v2` tag (if it exists). +git tag -f v2 v2.2.0 ``` -If you don't use `asdf`, then you need to: -1. Open the `./tool-versions` file in the root of the repo. -2. Make note of the NodeJS version listed in the `.tool-versions` file. -3. Install that same version of NodeJS on your machine. -4. Make sure that you are currently using that version of NodeJS (i.e. it is at the front of your PATH). - -## Step 3: Edit the `version` field in `package.json` +Step 3: Now you need to push the tags: ```bash -vim package.json +# Regular-push the new `v2.2.0` tag: +git push origin tag v2.2.0 -# Edit the `version` number (should be line 2) -# Save your changes in Vim. Then exit Vim. - -# For the remaining of this guide, let MAJOR.MINOR.PATCH refer -# to the new version number that you set. - -git add package.json - -# No need to commit yet. -# The release script will run `git commit`. +# Force-push the new v2 tag: +git push origin tag v2 --force ``` -## Step 4: Remove the `dist/` line from the `.gitignore` file +## Part 2: Create the GitHub Release -```bash -vim .gitignore -# Delete the line that says `dist/` (it should be line 3) -# Save your changes in Vim. Then exit Vim. +Go to the [Releases](https://github.com/julia-actions/setup-julia/releases) section of this repo and create a new release (using the GitHub web interface). -git add .gitignore - -# No need to commit yet. -# The release script will run `git commit`. -``` - -## Step 5: Make sure you have the necessary dependencies - -The `build-release.sh` script requires the following dependencies: - -1. Bash -2. `curl` -3. `git` -4. `jq` -5. `sed` - -## Step 6: Run the `build-release.sh` script - -```bash -ls -l bin/build-release.sh -chmod +x bin/build-release.sh -ls -l bin/build-release.sh - -./bin/build-release.sh julia-actions/setup-julia -``` - -Wait a minute or two. The script will build everything and will create a new release branch named `releases/vMAJOR.MINOR.PATCH`. - -## Step 7: Push ONLY the `releases/vMAJOR.MINOR.PATCH` branch - -Only push the `releases/` branch. Do NOT push any tags yet. - -```bash -git push origin releases/vMAJOR.MINOR.PATCH -``` - -Now you need to go to https://github.com/julia-actions/setup-julia/tree/releases/vMAJOR.MINOR.PATCH and wait for CI to finish running. - -Do NOT proceed to the next step until CI is all green on the `releases/vMAJOR.MINOR.PATCH` branch. - -## Step 8: Push the tags (only after CI is all green) - -Once CI is all green on the `releases/vMAJOR.MINOR.PATCH` branch, you can push the tags. - -You need to force-push. - -```bash -git push --tags --force -``` - -## Step 9: Use the GitHub web UI to create a new GitHub Release - -Go to https://github.com/julia-actions/setup-julia/releases and create a new release for the now-existant `vMAJOR.MINOR.PATCH` tag using the GitHub web interface. - -## Step 10: Clean up your local repo - -```bash -git submodule deinit --force . -git submodule update --init -git fetch --all --prune -git checkout master -git reset --hard origin/master -``` - -## Step 11: Delete your local repo - -```bash -cd .. -ls setup-julia -rm -rf setup-julia -``` +For the "choose a tag" drop-down field, select the `v2.2.0` tag that you created and pushed in Part 1 of this guide. diff --git a/package-lock.json b/package-lock.json index 8e15912..8d29510 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,10 @@ { "name": "setup-julia", - "version": "2.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "setup-julia", - "version": "2.3.0", "license": "MIT", "dependencies": { "@actions/core": "^1.10.1", diff --git a/package.json b/package.json index ce3547e..ffa390b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,5 @@ { "name": "setup-julia", - "version": "2.4.0", "private": true, "description": "setup Julia action", "main": "lib/setup-julia.js",