Skip to content

Commit

Permalink
Upgrade to Node 16, actions/core 1.10.0, actions/exec 1.1.1, actions/…
Browse files Browse the repository at this point in the history
…github 5.1.1
  • Loading branch information
Nuru committed Oct 26, 2022
2 parents bf3d76b + 68b46dd commit 32acf31
Show file tree
Hide file tree
Showing 7 changed files with 1,899 additions and 8,107 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.3.0
hooks:
- id: check-json
- id: check-yaml
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.0.0-beta.1
rev: v8.26.0
hooks:
- id: eslint
args: [--fix]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dist/index.js: index.js node_modules
node_modules/.bin/webpack --config webpack.config.js
# terrible hack to prevent lookup of `navigator`
# if someone knows the correct way to use webpack, PRs welcome!
sed -i 's/\bnavigator\b/({})/g' $@
# sed -i 's/\bnavigator\b/({})/g' $@

.PHONY: push
push: venv
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ inputs:
default: 'pre-commit fixes'

runs:
using: 'node12'
using: 'node16'
main: 'dist/index.js'
16 changes: 2 additions & 14 deletions dist/index.js

Large diffs are not rendered by default.

21 changes: 0 additions & 21 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const fs = require('fs');
const os = require('os');
const path = require('path');

const cache = require('@actions/cache');
const core = require('@actions/core');
const exec = require('@actions/exec');
const github = require('@actions/github');
Expand Down Expand Up @@ -51,27 +50,7 @@ async function main() {
const pr = github.context.payload.pull_request;
const push = !!token && !!pr;

const cachePaths = [path.join(os.homedir(), '.cache', 'pre-commit')];
const py = getPythonVersion();
const cacheKey = `pre-commit-2-${hashString(py)}-${hashFile('.pre-commit-config.yaml')}`;
const restored = await cache.restoreCache(cachePaths, cacheKey);
const ret = await exec.exec('pre-commit', args, {ignoreReturnCode: push});
if (!restored) {
try {
await cache.saveCache(cachePaths, cacheKey);
} catch (e) {
core.warning(
`There was an error saving the pre-commit environments to cache:
${e.message || e}
This only has performance implications and won't change the result of your pre-commit tests.
If this problem persists on your default branch, you can try to fix it by editing your '.pre-commit-config.yaml'.
For example try to run 'pre-commit autoupdate' or simply add a blank line.
This will result in a different hash value and thus a different cache target.`.replace(/^ +/gm, '')
);
}
}

if (ret && push) {
// actions do not run on pushes made by actions.
Expand Down
Loading

0 comments on commit 32acf31

Please sign in to comment.