Skip to content

Commit 198d391

Browse files
committed
feat(linter): upgrade ratchet
Signed-off-by: Emilien Escalle <emilien.escalle@escemi.com>
1 parent 1934091 commit 198d391

File tree

1 file changed

+3
-80
lines changed

1 file changed

+3
-80
lines changed

.github/workflows/linter.yml

Lines changed: 3 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -186,86 +186,9 @@ jobs:
186186
187187
core.setOutput("files", filesOutput);
188188
189-
// Add problem matcher for ratchet
190-
// FIXME: should retrieve ratchet file and line. See https://github.com/sethvargo/ratchet/issues/103.
191-
const problemMatcher = {
192-
"problemMatcher": [
193-
{
194-
"owner": "ratchet",
195-
"pattern": [
196-
{ "regexp": "^found (\\d) unpinned refs: \\[([^\\]]+)\\]$", "message": 0 }
197-
]
198-
}
199-
]
200-
};
201-
202-
fs.writeFileSync("ratchet-problem-matcher.json", JSON.stringify(problemMatcher, null, 2));
203-
204-
# FIXME: use actions/github-script, needs: https://github.com/actions/toolkit/pull/2001
205-
- if: ${{ steps.get-files-to-lint.outputs.files }}
206-
run: echo "::add-matcher::ratchet-problem-matcher.json"
207-
208189
- id: ratchet
209-
uses: "docker://ghcr.io/sethvargo/ratchet:0.10.2@sha256:78f70ed0c85830a78bd9eeb265f49aa375d71887e4245aebc5da9c641d76b245" # v0.10.2
190+
# FIXME: should be updated by dependabot. See https://github.com/dependabot/dependabot-core/issues/8362
191+
uses: "docker://ghcr.io/sethvargo/ratchet:0.11.0@sha256:f0849ca45ef2bd374633cca5eed5e0f13d825789f90df18f199c3c289002daa2" # 0.11.0
210192
if: ${{ steps.get-files-to-lint.outputs.files }}
211193
with:
212-
args: "check ${{ steps.get-files-to-lint.outputs.files }}"
213-
214-
- if: ${{ always() && steps.get-files-to-lint.outputs.files }}
215-
run: echo "::remove-matcher owner=ratchet::"
216-
217-
- if: ${{ failure() && steps.get-files-to-lint.outputs.files }}
218-
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
219-
with:
220-
script: |
221-
const ratchetOutcome = ${{ toJSON(steps.ratchet.outcome) }};
222-
223-
if (ratchetOutcome !== "failure") {
224-
return;
225-
}
226-
227-
// FIXME: should retrieve ratchet error output. See https://github.com/sethvargo/ratchet/issues/103.
228-
const ratchetErrorsOutputs = ${{ toJSON(steps.ratchet.outputs.errors) }};
229-
if (!ratchetErrorsOutputs || ratchetErrorsOutputs.length === 0) {
230-
return;
231-
}
232-
233-
// Format the ratchet errors: found x unpinned refs: ...
234-
const unpinnedRefsError = /found (\d+) unpinned refs: (.*)/g.exec(ratchetErrorsOutputs[0]);
235-
if (!unpinnedRefsError) {
236-
return;
237-
}
238-
239-
const unpinnedRefs = JSON.parse(unpinnedRefsError[2]);
240-
241-
async function getFileErrors(file) {
242-
const fileContent = await fs.promises.readFile(file, "utf8");
243-
244-
const errors = [];
245-
246-
for(const unpinnedRef of unpinnedRefs) {
247-
if(fileContent.includes(unpinnedRef)) {
248-
errors.push(file);
249-
}
250-
}
251-
252-
return errors;
253-
}
254-
255-
const files = ${{ toJSON(steps.get-files-to-lint.outputs.files) }}.split(" ");
256-
257-
// Annotate file errors
258-
await Promise.all(files.map(async (file) => {
259-
const errors = await getFileErrors(file);
260-
if (errors.length === 0) {
261-
return;
262-
}
263-
264-
core.error(
265-
`Found ${errors.length} unpinned refs`,
266-
{
267-
title: `Unpinned refs: ${JSON.stringify(errors)}`,
268-
file: file
269-
}
270-
);
271-
}));
194+
args: "lint --format human --format actions ${{ steps.get-files-to-lint.outputs.files }}"

0 commit comments

Comments
 (0)