feat: fix nondeterministic hash with globbing, update to node20 and update pipelines

This commit is contained in:
Jakub Janusz 2025-07-25 18:20:25 +02:00
parent 937867e5ad
commit 2edc564e26
12 changed files with 7810 additions and 3343 deletions

View File

@ -21,12 +21,12 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Set Node.js 16.x - name: Set Node.js 20.x
uses: actions/setup-node@v3.6.0 uses: actions/setup-node@v4
with: with:
node-version: 16.x node-version: 20.x
- name: Install dependencies - name: Install dependencies
run: npm ci run: npm ci
@ -46,7 +46,7 @@ jobs:
id: diff id: diff
# If index.js was different than expected, upload the expected version as an artifact # If index.js was different than expected, upload the expected version as an artifact
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v4
if: ${{ failure() && steps.diff.conclusion == 'failure' }} if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with: with:
name: dist name: dist

View File

@ -38,11 +38,11 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v4
# Initializes the CodeQL tools for scanning. # Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v2 uses: github/codeql-action/init@v3
with: with:
languages: ${{ matrix.language }} languages: ${{ matrix.language }}
source-root: src source-root: src
@ -54,7 +54,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below) # If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild - name: Autobuild
uses: github/codeql-action/autobuild@v2 uses: github/codeql-action/autobuild@v3
# Command-line programs to run using the OS shell. # Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl # 📚 https://git.io/JvXDl
@ -68,4 +68,4 @@ jobs:
# make release # make release
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2 uses: github/codeql-action/analyze@v3

View File

@ -10,7 +10,7 @@ jobs:
build: # make sure build/ci work properly build: # make sure build/ci work properly
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- run: | - run: |
npm install npm install
- run: | - run: |
@ -19,7 +19,7 @@ jobs:
test: # make sure the action works on a clean machine without building test: # make sure the action works on a clean machine without building
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: ./ - uses: ./
id: get-hash id: get-hash

13
.vscode/settings.json vendored
View File

@ -1,12 +1,15 @@
{ {
// eslint // Run eslint on save
"editor.codeActionsOnSave": { "editor.codeActionsOnSave": {
"source.fixAll.eslint": true "source.fixAll.eslint": true
}, },
// // Never show expanded abbreviation
"emmet.showExpandedAbbreviation": "never", "emmet.showExpandedAbbreviation": "never",
// // Disable code minimap
"editor.minimap.enabled": false, "editor.minimap.enabled": false,
// // Wrap long lines
"editor.wordWrap": "on" "editor.wordWrap": "on",
"yaml.schemas": {
"https://www.artillery.io/schema.json": []
}
} }

View File

@ -6,23 +6,23 @@ import * as path from 'path'
import {test} from '@jest/globals' import {test} from '@jest/globals'
test('test sha256', async () => { test('test sha256', async () => {
console.log(hashHex('this is content')) console.info(hashHex('this is content'))
}) })
test('test sha512', async () => { test('test sha512', async () => {
console.log(hashHex('this is content', 'sha512')) console.info(hashHex('this is content', 'sha512'))
}) })
test('test readFile', async () => { test('test readFile', async () => {
const content = await readFile('./.prettierignore') const content = await readFile('./.prettierignore')
console.log(content) console.info(content)
}) })
test('test getFiles', async () => { test('test getFiles', async () => {
const paths = await getFiles('./', ['**/*.ts', '**/package-lock.json'], { const paths = await getFiles('./', ['**/*.ts', '**/package-lock.json'], {
gitignore: true gitignore: true
}) })
console.log(paths) console.info(paths)
}) })
test('test runs', () => { test('test runs', () => {
@ -34,5 +34,5 @@ test('test runs', () => {
const options: cp.ExecFileSyncOptions = { const options: cp.ExecFileSyncOptions = {
env: process.env env: process.env
} }
console.log(cp.execFileSync(np, [ip], options).toString()) console.info(cp.execFileSync(np, [ip], options).toString())
}) })

View File

@ -15,10 +15,10 @@ inputs:
gitignore: gitignore:
description: > description: >
Respect ignore patterns in .gitignore files that apply to the globbed files. Respect ignore patterns in .gitignore files that apply to the globbed files.
default: true default: 'true'
required: false required: false
ignoreFiles: ignoreFiles:
descruption: > description: >
Glob patterns to look for ignore files, which are then used to ignore globbed files. Glob patterns to look for ignore files, which are then used to ignore globbed files.
This is a more generic form of the gitignore option, allowing you to find ignore files with a compatible syntax. This is a more generic form of the gitignore option, allowing you to find ignore files with a compatible syntax.
For instance, this works with Babel's .babelignore, Prettier's .prettierignore, or ESLint's .eslintignore files. For instance, this works with Babel's .babelignore, Prettier's .prettierignore, or ESLint's .eslintignore files.
@ -29,5 +29,5 @@ outputs:
matched-files: matched-files:
description: 'The files matched by the patterns' description: 'The files matched by the patterns'
runs: runs:
using: 'node16' using: 'node20'
main: 'dist/index.js' main: 'dist/index.js'

2194
dist/index.js generated vendored

File diff suppressed because it is too large Load Diff

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

37
dist/licenses.txt generated vendored
View File

@ -10,6 +10,18 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@actions/exec
MIT
The MIT License (MIT)
Copyright 2019 GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@actions/http-client @actions/http-client
MIT MIT
Actions Http Client for Node.js Actions Http Client for Node.js
@ -35,6 +47,18 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@actions/io
MIT
The MIT License (MIT)
Copyright 2019 GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@cjs-exporter/globby @cjs-exporter/globby
MIT MIT
@ -61,16 +85,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
uuid
MIT
The MIT License (MIT)
Copyright (c) 2010-2020 Robert Kieffer and other contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

8850
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -25,21 +25,24 @@
"author": "seepine", "author": "seepine",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.10.0", "@actions/core": "^1.11.1",
"@cjs-exporter/globby": "^13.1.3", "@cjs-exporter/globby": "^13.1.3"
"crypto": "^1.0.1"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^18.16.3", "@types/node": "^20.19.4",
"@typescript-eslint/parser": "^5.59.2", "@typescript-eslint/parser": "^5.59.2",
"@vercel/ncc": "^0.36.1", "@vercel/ncc": "^0.36.1",
"eslint": "^8.39.0", "eslint": "^8.39.0",
"eslint-plugin-github": "^4.7.0", "eslint-plugin-github": "^4.7.0",
"eslint-plugin-jest": "^27.2.1", "eslint-plugin-jest": "^27.2.1",
"eslint-plugin-prettier": "^5.5.3",
"jest": "^29.5.0", "jest": "^29.5.0",
"js-yaml": "^4.1.0", "js-yaml": "^4.1.0",
"prettier": "^2.8.8", "prettier": "^3.0.0",
"ts-jest": "^29.1.0", "ts-jest": "^29.1.0",
"typescript": "^5.0.4" "typescript": "^5.8.3"
},
"engines": {
"node": ">=20"
} }
} }

View File

@ -22,7 +22,9 @@ async function run(): Promise<void> {
core.debug(`gitignore: ${gitignore}`) core.debug(`gitignore: ${gitignore}`)
core.debug(`ignoreFiles: ${ignoreFiles}`) core.debug(`ignoreFiles: ${ignoreFiles}`)
const files = await getFiles(workdir, patterns, {gitignore, ignoreFiles}) const files = (
await getFiles(workdir, patterns, {gitignore, ignoreFiles})
).sort((a, b) => a.localeCompare(b))
let hash = '' let hash = ''
const reads = files.map(async file => readFile(file)) const reads = files.map(async file => readFile(file))