Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 7 additions & 7 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
version: 2
updates:
- package-ecosystem: 'github-actions'
- package-ecosystem: "github-actions"
directory: /
schedule:
interval: weekly
groups:
actions-deps:
patterns:
- '*'
- "*"

- package-ecosystem: npm
- package-ecosystem: bun
directory: /
schedule:
interval: monthly
groups:
security-updates:
applies-to: security-updates
patterns:
- '*'
- "*"
major-updates:
applies-to: version-updates
update-types:
- 'major'
- "major"
minor-updates:
applies-to: version-updates
update-types:
- 'minor'
- 'patch'
- "minor"
- "patch"
9 changes: 4 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ jobs:
steps:
- uses: actions/checkout@v6

- uses: actions/setup-node@v6
- uses: oven-sh/setup-bun@v2
with:
node-version: 22
cache: "npm"
bun-version: 1.3.11

- name: Install dependencies
run: npm install
run: bun install

- name: Run all checks
run: npm run all
run: bun run all
26 changes: 26 additions & 0 deletions .github/workflows/update-tags.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Update aggregate tags"
on:
push:
tags:
- "v*.*"

jobs:
retag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Calculate short tag name
id: calculate_short_tag
run: |
TRUNC_VER=$(echo ${{ github.ref_name }} | cut -d '.' -f 1)
echo "Short tag: $TRUNC_VER"
echo "tag=$TRUNC_VER" >> $GITHUB_OUTPUT
- uses: rickstaa/action-create-tag@v1
permissions:
contents: write
with:
force_push_tag: true
tag: "${{ steps.calculate_short_tag.outputs.tag }}"
message: "Points to ${{ github.ref_name }}"
86 changes: 0 additions & 86 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,99 +1,13 @@
# Dependency directory
node_modules

# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# OS metadata
.DS_Store
Thumbs.db

# Ignore built ts files
__tests__/runner/*
lib
87 changes: 42 additions & 45 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,34 @@ type TestFile = {
};
const TEST_FILES: TestFile[] = [
{
diff: "===================================================================%0A--- FIXTURES/file1_basic.txt%0A+++ FIXTURES/file2_deleted.txt%0A@@ -1,4 +1,3 @@%0A A%0A-B%0A C%0A D%0A",
path: "file2_deleted.txt",
tolerance: "worse",
diff: "===================================================================%0A--- FIXTURES/file1_basic.txt%0A+++ FIXTURES/file2_deleted.txt%0A@@ -1,4 +1,3 @@%0A A%0A-B%0A C%0A D%0A",
},
{
diff: "===================================================================%0A--- FIXTURES/file1_basic.txt%0A+++ FIXTURES/file3_same.txt%0A",
path: "file3_same.txt",
tolerance: "same",
diff: "===================================================================%0A--- FIXTURES/file1_basic.txt%0A+++ FIXTURES/file3_same.txt%0A",
},
{
diff: "===================================================================%0A--- FIXTURES/file1_basic.txt%0A+++ FIXTURES/file4_added.txt%0A@@ -1,4 +1,5 @@%0A A%0A B%0A C%0A D%0A+E%0A",
path: "file4_added.txt",
tolerance: "better",
diff: "===================================================================%0A--- FIXTURES/file1_basic.txt%0A+++ FIXTURES/file4_added.txt%0A@@ -1,4 +1,5 @@%0A A%0A B%0A C%0A D%0A+E%0A",
},
{
diff: "===================================================================%0A--- FIXTURES/file1_basic.txt%0A+++ FIXTURES/file5_mixed.txt%0A@@ -1,4 +1,4 @@%0A A%0A B%0A-C%0A D%0A+E%0A",
path: "file5_mixed.txt",
tolerance: "mixed",
diff: "===================================================================%0A--- FIXTURES/file1_basic.txt%0A+++ FIXTURES/file5_mixed.txt%0A@@ -1,4 +1,4 @@%0A A%0A B%0A-C%0A D%0A+E%0A",
},
{
diff: "===================================================================%0A--- FIXTURES/file1_basic.txt%0A+++ FIXTURES/file6_mixed_added.txt%0A@@ -1,4 +1,5 @@%0A A%0A B%0A-C%0A D%0A+E%0A+F%0A",
path: "file6_mixed_added.txt",
tolerance: "mixed-better",
diff: "===================================================================%0A--- FIXTURES/file1_basic.txt%0A+++ FIXTURES/file6_mixed_added.txt%0A@@ -1,4 +1,5 @@%0A A%0A B%0A-C%0A D%0A+E%0A+F%0A",
},
{
diff: "===================================================================%0A--- FIXTURES/file1_basic.txt%0A+++ FIXTURES/file7_mixed_deleted.txt%0A@@ -1,4 +1,3 @@%0A A%0A B%0A-C%0A-D%0A+E%0A",
path: "file7_mixed_deleted.txt",
tolerance: "mixed-worse",
diff: "===================================================================%0A--- FIXTURES/file1_basic.txt%0A+++ FIXTURES/file7_mixed_deleted.txt%0A@@ -1,4 +1,3 @@%0A A%0A B%0A-C%0A-D%0A+E%0A",
},
];

Expand Down Expand Up @@ -95,8 +95,8 @@ describe("run action", () => {
};

const parseOutput = (actionOutput: string): ActionOutputs => {
let passed: boolean | undefined = undefined;
let output: string | undefined = undefined;
let passed: boolean | undefined;
let output: string | undefined;
for (const line of actionOutput.split("\n")) {
if (line.startsWith("::set-output name=passed::")) {
passed = line.split("::set-output name=passed::")[1] === "true";
Expand All @@ -108,7 +108,7 @@ describe("run action", () => {
if (passed === undefined || output === undefined) {
throw new Error("Action did not return expected output");
}
return { passed, output };
return { output, passed };
};

const runAction = (
Expand All @@ -122,7 +122,7 @@ describe("run action", () => {
process.env.INPUT_TOLERANCE = tolerance.toString();
process.env.INPUT_MODE = mode.toString();
process.env.GITHUB_OUTPUT = "";
const main = path.join(__dirname, "..", "lib", "main.js");
const main = path.join(__dirname, "..", "dist", "index.js");
const options: cp.ExecSyncOptions = {
env: process.env,
};
Expand Down Expand Up @@ -160,25 +160,25 @@ describe("run action", () => {
const cases = ((): Case[] => {
const cases: Case[] = [
{
expectError: true,
mode: "strict",
name: "an unknown file",
newFile: "do not exist . whatever",
mode: "strict",
tolerance: "same",
expectError: true,
},
{
expectError: true,
mode: "mixed" as unknown as Mode,
name: "an unknown mode",
newFile: TEST_FILES[0].path,
mode: "mixed" as unknown as Mode,
tolerance: "same",
expectError: true,
},
{
expectError: true,
mode: "addition",
name: "an unknown tolerance",
newFile: TEST_FILES[0].path,
mode: "addition",
tolerance: "high" as unknown as Tolerance,
expectError: true,
},
];

Expand All @@ -195,13 +195,13 @@ describe("run action", () => {
result = "an error";
}
cases.push({
expectError,
expectedOutput: file.diff,
expectedPass,
mode: mode,
name: `file ${file.path}, mode ${mode}, tolerance ${tolerance} and expecting ${result}`,
newFile: file.path,
tolerance: tolerance,
mode: mode,
expectedPass,
expectedOutput: file.diff,
expectError,
});
}
}
Expand All @@ -210,34 +210,31 @@ describe("run action", () => {
return cases;
})();

test.each(cases)(
"with $name",
({
newFile,
test.each(cases)("with $name", ({
newFile,
tolerance,
mode,
expectedPass,
expectedOutput,
expectError,
}: Case) => {
if (expectError) {
expect(() => {
runAction(BASE_FILE, newFile, tolerance, mode);
}).toThrow();
return;
}
const { passed, output } = runAction(
BASE_FILE,
path.join(FIXTURES_FOLDER, newFile),
tolerance,
mode,
expectedPass,
);
expect(passed).toBe(expectedPass);
expect(output.replace(new RegExp(FIXTURES_FOLDER, "g"), "FIXTURES")).toBe(
expectedOutput,
expectError,
}: Case) => {
if (expectError) {
expect(() => {
runAction(BASE_FILE, newFile, tolerance, mode);
}).toThrow();
return;
}
const { passed, output } = runAction(
BASE_FILE,
path.join(FIXTURES_FOLDER, newFile),
tolerance,
mode,
);
expect(passed).toBe(expectedPass);
expect(output.replace(new RegExp(FIXTURES_FOLDER, "g"), "FIXTURES")).toBe(
expectedOutput,
);
},
);
);
});
});

// TODO: missing tests for notifications?
Loading
Loading