Compare commits

..

251 Commits
v3.5.0 ... v5

Author SHA1 Message Date
38e1018663 feat: improve log about pwd/cwd (#1033) 2024-05-05 01:13:21 +02:00
21e9e6b47f feat: use OS and working-directory as cache key (#1032) 2024-05-04 18:43:48 +02:00
dbe4fc23f1 chore: use getBooleanInput 2024-05-04 17:49:04 +02:00
dbb7ebcd4c feat: add option to control cache invalidation interval (#1031) 2024-05-04 17:47:25 +02:00
ecb32920c6 feat: uses 2 dots compare syntax for push diff (#1030) 2024-05-04 16:54:30 +02:00
046435d14c doc: improve options documentation 2024-05-04 02:42:39 +02:00
ca8befdfb6 doc: improve options documentation 2024-05-04 02:36:06 +02:00
d9c9b53e53 chore: improve marketplace style 2024-05-04 01:41:30 +02:00
aebff4bd9c feat: add option to enable/disable annotations 2024-05-04 01:40:50 +02:00
2bff406277 doc: improve options documentation 2024-05-04 01:27:11 +02:00
7a6f31107b doc: improve options description 2024-05-04 01:17:12 +02:00
57c4c9d189 docs: update readme 2024-05-04 00:37:42 +02:00
3519a25e89 chore: update tests workflow 2024-05-04 00:37:42 +02:00
d073fb8ea7 doc: add information about annotation limitations 2024-05-01 04:24:14 +02:00
9d1e0624a7 feat: only new issues enhancements (#1029) 2024-04-29 17:07:23 +02:00
692c9c9dba build(deps-dev): bump @typescript-eslint/eslint-plugin from 7.7.0 to 7.7.1 (#1028) 2024-04-29 13:56:18 +02:00
ef6d5d0e99 build(deps-dev): bump @typescript-eslint/parser from 7.7.0 to 7.7.1 (#1027) 2024-04-29 13:37:38 +02:00
d149ece3f4 docs: update readme 2024-04-27 04:18:26 +02:00
f89fd48199 docs: update readme 2024-04-27 03:06:28 +02:00
47ef1b2e7f docs: update readme 2024-04-26 17:25:34 +02:00
7c0f80cbb8 docs: update readme 2024-04-25 03:39:35 +02:00
3adb6d0473 docs: update readme 2024-04-25 03:38:07 +02:00
03a8ce6d60 docs: update readme 2024-04-25 03:35:41 +02:00
82d40c283a feat: remove Go cache management (#1024) 2024-04-25 03:26:57 +02:00
c683728f10 feat: add option to not save cache (#851) 2024-04-25 01:17:21 +00:00
bf6479d5ec feat: add support for pull_request_target and only-new-issues (#506) 2024-04-25 03:03:53 +02:00
d6238b002a build(deps-dev): bump @typescript-eslint/eslint-plugin from 7.6.0 to 7.7.0 (#1023) 2024-04-22 16:53:44 +02:00
847b9efe2e build(deps-dev): bump @typescript-eslint/parser from 7.5.0 to 7.7.0 (#1022) 2024-04-22 11:09:08 +02:00
019c5ec617 build(deps-dev): bump eslint-plugin-simple-import-sort from 12.0.0 to 12.1.0 (#1018) 2024-04-15 11:30:10 +00:00
3dea681709 build(deps-dev): bump @typescript-eslint/eslint-plugin from 7.5.0 to 7.6.0 (#1019) 2024-04-15 13:23:06 +02:00
155e5ebdeb build(deps-dev): bump typescript from 5.4.4 to 5.4.5 (#1017) 2024-04-15 13:22:12 +02:00
14117827cf build(deps): bump @types/node from 20.12.5 to 20.12.7 (#1016) 2024-04-15 13:21:54 +02:00
e3c1789d3f build(deps-dev): bump @typescript-eslint/parser from 7.4.0 to 7.5.0 (#1014) 2024-04-08 15:02:41 +02:00
24de455de2 build(deps-dev): bump @typescript-eslint/eslint-plugin from 7.4.0 to 7.5.0 (#1013) 2024-04-08 13:31:32 +02:00
0068957dcf build(deps): bump @types/node from 20.12.2 to 20.12.5 (#1012) 2024-04-08 13:31:06 +02:00
8cca243457 build(deps-dev): bump typescript from 5.4.3 to 5.4.4 (#1011) 2024-04-08 13:30:51 +02:00
c1ec8d27ed build(deps): bump undici from 5.28.3 to 5.28.4 (#1010)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2024-04-04 21:23:29 +02:00
80ffcf7ac5 build(deps-dev): bump @typescript-eslint/parser from 7.3.1 to 7.4.0 (#1009) 2024-04-01 16:07:04 +02:00
c9cf8614bf build(deps-dev): bump @typescript-eslint/eslint-plugin from 7.3.1 to 7.4.0 (#1008) 2024-04-01 14:50:56 +02:00
ca92b655d7 build(deps): bump @types/node from 20.11.30 to 20.12.2 (#1007) 2024-04-01 14:50:30 +02:00
e637d2bbe4 build(deps-dev): bump @typescript-eslint/parser from 7.2.0 to 7.3.1 (#1006) 2024-03-25 11:54:13 +00:00
f7e6ffb14d build(deps-dev): bump typescript from 5.4.2 to 5.4.3 (#1005) 2024-03-25 12:42:58 +01:00
04092870fd build(deps): bump @types/node from 20.11.28 to 20.11.30 (#1004) 2024-03-25 12:42:27 +01:00
15ace4fc54 build(deps-dev): bump @typescript-eslint/eslint-plugin from 7.2.0 to 7.3.1 (#1003) 2024-03-25 12:42:10 +01:00
66db41e5dd build(deps-dev): bump @typescript-eslint/eslint-plugin from 7.1.1 to 7.2.0 (#999) 2024-03-18 13:41:34 +01:00
a54aa6ce0b build(deps): bump @types/node from 20.11.25 to 20.11.28 (#1000) 2024-03-18 13:22:57 +01:00
0cb4e4ce8a build(deps-dev): bump @typescript-eslint/parser from 7.1.1 to 7.2.0 (#998) 2024-03-18 13:22:29 +01:00
c2b1114313 build(deps): bump google.golang.org/protobuf from 1.28.0 to 1.33.0 in /sample-go-mod (#997) 2024-03-13 23:01:31 +01:00
1ef822c9e7 build(deps): bump @actions/http-client from 2.2.0 to 2.2.1 (#995)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2024-03-11 19:03:02 +01:00
0cf702c571 build(deps-dev): bump @typescript-eslint/eslint-plugin from 7.1.0 to 7.1.1 (#994) 2024-03-11 17:35:13 +01:00
e0e0b2b842 build(deps-dev): bump typescript from 5.3.3 to 5.4.2 (#993) 2024-03-11 17:23:20 +01:00
d7b3f577a7 build(deps): bump @types/node from 20.11.24 to 20.11.25 (#992) 2024-03-11 17:23:00 +01:00
a3062e4021 build(deps-dev): bump @typescript-eslint/parser from 7.1.0 to 7.1.1 (#991) 2024-03-11 17:22:40 +01:00
0cea014686 build(deps): bump @types/node from 20.11.20 to 20.11.24 (#990) 2024-03-04 13:43:42 +01:00
c9cca96908 build(deps-dev): bump @typescript-eslint/parser from 6.21.0 to 7.1.0 (#988)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2024-03-04 13:40:26 +01:00
2e99f461f3 build(deps): bump tmp from 0.2.1 to 0.2.3 (#989)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2024-03-04 13:36:42 +01:00
27463c1456 build(deps-dev): bump eslint from 8.56.0 to 8.57.0 (#987) 2024-02-26 17:04:02 +01:00
47f5f04922 build(deps): bump @types/semver from 7.5.7 to 7.5.8 (#986) 2024-02-26 13:09:12 +00:00
6d0160cbf8 build(deps): bump @types/node from 20.11.19 to 20.11.20 (#985) 2024-02-26 14:00:14 +01:00
52b846a8b5 build(deps): bump undici from 5.26.3 to 5.28.3 (#976)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2024-02-19 15:35:38 +01:00
3f7fc68782 build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.21.0 to 7.0.0 (#980) 2024-02-19 14:40:55 +01:00
1eba11c6d8 build(deps): bump @types/node from 20.11.17 to 20.11.19 (#979) 2024-02-19 14:40:33 +01:00
552a57d5dc docs: update the version of the action used in the README example (#977)
Co-authored-by: Ludovic Fernandez <ldez@users.noreply.github.com>
2024-02-17 15:43:17 +00:00
a83e3d11f6 build(deps): bump @types/node from 20.11.16 to 20.11.17 (#972) 2024-02-12 16:33:45 +01:00
2fc4c770fc build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.20.0 to 6.21.0 (#973) 2024-02-12 16:33:36 +01:00
0ea26a0a52 build(deps-dev): bump eslint-plugin-simple-import-sort from 10.0.0 to 12.0.0 (#971) 2024-02-12 15:12:04 +01:00
f1a742892f build(deps-dev): bump @typescript-eslint/parser from 6.20.0 to 6.21.0 (#970) 2024-02-12 15:11:56 +01:00
2031bb15ab build(deps): bump @types/semver from 7.5.6 to 7.5.7 (#969) 2024-02-12 15:11:44 +01:00
17bf0db4b7 chore: use olstable as Go version 2024-02-12 14:12:44 +01:00
de85e3b9b1 chore: update tested golangci-lint version 2024-02-12 13:57:04 +01:00
3cfe3a4abb build(deps): bump @actions/cache from 3.2.3 to 3.2.4 (#963)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2024-02-05 17:45:40 +00:00
cbc59cf0d1 build(deps-dev): bump prettier from 3.2.4 to 3.2.5 (#960) 2024-02-05 18:03:56 +01:00
459a04b021 build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.19.1 to 6.20.0 (#959) 2024-02-05 18:03:36 +01:00
e2315b67db build(deps-dev): bump @typescript-eslint/parser from 6.19.1 to 6.20.0 (#961) 2024-02-05 14:10:30 +01:00
d6173a45d0 build(deps): bump @types/node from 20.11.10 to 20.11.16 (#962) 2024-02-05 14:10:22 +01:00
0e8f5bf773 build(deps): bump @types/node from 20.11.5 to 20.11.10 (#958) 2024-01-29 17:58:17 +01:00
349d20632d build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.19.0 to 6.19.1 (#957) 2024-01-29 13:44:07 +01:00
2221aee284 build(deps-dev): bump @typescript-eslint/parser from 6.18.1 to 6.19.1 (#954) 2024-01-22 23:29:21 +01:00
3b44ae5b24 build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.18.1 to 6.19.0 (#951) 2024-01-22 22:31:10 +01:00
323b871bbc build(deps-dev): bump prettier from 3.2.2 to 3.2.4 (#950) 2024-01-22 22:30:59 +01:00
a23373f4c8 build(deps): bump @types/node from 20.11.1 to 20.11.5 (#949) 2024-01-22 22:30:46 +01:00
e38f944096 build(deps): bump @actions/cache from 3.2.2 to 3.2.3 (#946)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2024-01-16 16:26:51 +00:00
3c5e1cac39 build(deps): bump @types/node from 20.10.7 to 20.11.1 (#948) 2024-01-15 14:20:05 +01:00
0f1139540c build(deps-dev): bump prettier from 3.1.1 to 3.2.2 (#947) 2024-01-15 14:19:57 +01:00
81218f8e0c build(deps-dev): bump @typescript-eslint/parser from 6.18.0 to 6.18.1 (#945) 2024-01-15 14:19:47 +01:00
cc439c2555 build(deps-dev): bump eslint-plugin-prettier from 5.1.2 to 5.1.3 (#944) 2024-01-15 14:19:38 +01:00
3efd423e8d build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.16.0 to 6.18.1 (#942) 2024-01-09 00:26:23 +01:00
effc519e1b build(deps): bump @types/node from 20.10.6 to 20.10.7 (#941) 2024-01-09 00:08:47 +01:00
cfaf0f0750 build(deps-dev): bump @typescript-eslint/parser from 6.16.0 to 6.18.0 (#939) 2024-01-09 00:08:24 +01:00
86abc3c6d2 build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.15.0 to 6.16.0 (#936) 2024-01-01 19:41:21 +01:00
c5ba143a4c build(deps): bump @types/node from 20.10.5 to 20.10.6 (#937) 2024-01-01 13:37:18 +01:00
a9d24cbbd7 build(deps-dev): bump @typescript-eslint/parser from 6.15.0 to 6.16.0 (#935) 2024-01-01 13:36:46 +01:00
2e6adf08a9 build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.14.0 to 6.15.0 (#934) 2023-12-25 16:53:12 +01:00
1c2ceb7f27 build(deps-dev): bump @typescript-eslint/parser from 6.14.0 to 6.15.0 (#933) 2023-12-25 16:33:00 +01:00
5f85afe386 build(deps-dev): bump eslint-plugin-prettier from 5.0.1 to 5.1.2 (#932) 2023-12-25 16:32:40 +01:00
05d79cc0e4 docs: update section about GitHub Annotations (#931) 2023-12-21 17:04:32 +01:00
edcd1211b8 build(deps-dev): bump eslint from 8.55.0 to 8.56.0 (#930) 2023-12-18 12:47:25 +01:00
eb69bf92e7 build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.13.2 to 6.14.0 (#928) 2023-12-18 10:49:05 +00:00
92ed864d2e build(deps): bump @types/node from 20.10.4 to 20.10.5 (#929) 2023-12-18 11:34:10 +01:00
3eeea96a33 build(deps-dev): bump eslint-plugin-import from 2.29.0 to 2.29.1 (#927) 2023-12-18 11:33:42 +01:00
c701339303 build(deps-dev): bump @typescript-eslint/parser from 6.13.2 to 6.14.0 (#926) 2023-12-18 11:33:23 +01:00
e03e943597 build(deps): bump github/codeql-action from 2 to 3 (#925) 2023-12-18 11:33:01 +01:00
50372b6518 build(deps-dev): bump typescript from 5.3.2 to 5.3.3 (#923) 2023-12-11 11:12:25 +00:00
b6b6b379de build(deps): bump actions/setup-go from 4 to 5 (#924) 2023-12-11 12:03:51 +01:00
7d8fef21df build(deps-dev): bump prettier from 3.1.0 to 3.1.1 (#922) 2023-12-11 12:02:12 +01:00
0d0b9c12e8 build(deps): bump @types/node from 20.10.3 to 20.10.4 (#921) 2023-12-11 12:01:48 +01:00
7989493c23 build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.13.1 to 6.13.2 (#920) 2023-12-11 12:01:31 +01:00
f7e7174579 build(deps-dev): bump eslint-config-prettier from 9.0.0 to 9.1.0 (#916) 2023-12-05 05:38:38 +00:00
46a279bd0a build(deps-dev): bump @typescript-eslint/parser from 6.12.0 to 6.13.2 (#918) 2023-12-05 05:32:13 +00:00
4f796ce6b5 build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.12.0 to 6.13.1 (#915) 2023-12-05 06:21:59 +01:00
dd7bdbe4bf build(deps-dev): bump eslint from 8.54.0 to 8.55.0 (#914) 2023-12-05 06:21:41 +01:00
5e13907514 build(deps): bump @types/node from 20.10.0 to 20.10.3 (#913) 2023-12-05 06:20:38 +01:00
c0b0a00641 build(deps-dev): bump @typescript-eslint/parser from 6.11.0 to 6.12.0 (#911) 2023-11-27 17:06:01 +01:00
88688a2400 build(deps): bump @types/semver from 7.5.5 to 7.5.6 (#910) 2023-11-27 17:05:41 +01:00
a50083874e build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.11.0 to 6.12.0 (#909) 2023-11-27 16:54:04 +01:00
8e84a3001a build(deps-dev): bump typescript from 5.2.2 to 5.3.2 (#908) 2023-11-27 16:53:44 +01:00
9a8fa77b90 build(deps): bump @types/node from 20.9.2 to 20.10.0 (#907) 2023-11-27 16:49:13 +01:00
677d5e3b79 build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.10.0 to 6.11.0 (#906) 2023-11-20 12:05:25 +00:00
abd6e0ea0b build(deps-dev): bump @typescript-eslint/parser from 6.10.0 to 6.11.0 (#905) 2023-11-20 12:52:43 +01:00
7778b2da3c build(deps): bump @types/node from 20.8.10 to 20.9.2 (#904) 2023-11-20 12:52:26 +01:00
bfee5ee11d build(deps-dev): bump eslint from 8.53.0 to 8.54.0 (#903) 2023-11-20 12:52:14 +01:00
608f9e14ec docs: fix typos 2023-11-14 22:51:16 +01:00
9381bb2c2c build(deps-dev): bump @typescript-eslint/parser from 6.9.1 to 6.10.0 (#899) 2023-11-13 12:16:04 +01:00
17e44d79cb build(deps): bump @types/tmp from 0.2.5 to 0.2.6 (#898) 2023-11-13 12:15:55 +01:00
25ef9ca970 build(deps-dev): bump prettier from 3.0.3 to 3.1.0 (#900) 2023-11-13 11:57:04 +01:00
170a3a0cf1 build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.9.1 to 6.10.0 (#896) 2023-11-13 11:56:41 +01:00
a76f44e7d8 build(deps): bump @types/semver from 7.5.4 to 7.5.5 (#897) 2023-11-13 11:56:30 +01:00
8fa7dff7b9 build(deps-dev): bump @typescript-eslint/parser from 6.9.0 to 6.9.1 (#894) 2023-11-06 13:03:23 +00:00
face0856de build(deps): bump @types/node from 20.8.9 to 20.8.10 (#895) 2023-11-06 13:50:07 +01:00
ec66a939a9 build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.9.0 to 6.9.1 (#892) 2023-11-06 13:49:27 +01:00
c44dc93f23 build(deps-dev): bump eslint from 8.52.0 to 8.53.0 (#893) 2023-11-06 13:49:05 +01:00
d2a0133e31 build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.8.0 to 6.9.0 (#890) 2023-10-30 12:20:09 +00:00
455de4e66d build(deps): bump @types/node from 20.8.6 to 20.8.9 (#889) 2023-10-30 13:04:32 +01:00
61c1a4a9f5 build(deps-dev): bump @typescript-eslint/parser from 6.8.0 to 6.9.0 (#888) 2023-10-30 13:04:19 +01:00
604fe72b13 build(deps-dev): bump eslint-plugin-import from 2.28.1 to 2.29.0 (#887) 2023-10-30 13:04:09 +01:00
3c85045f6e build(deps): bump @types/tmp from 0.2.4 to 0.2.5 (#886) 2023-10-30 13:03:56 +01:00
d9fc28500d build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.7.5 to 6.8.0 (#884) 2023-10-23 17:52:37 +02:00
7d357a3513 build(deps-dev): bump @typescript-eslint/parser from 6.7.5 to 6.8.0 (#885) 2023-10-23 17:27:19 +02:00
b45661bc10 build(deps-dev): bump @vercel/ncc from 0.38.0 to 0.38.1 (#883) 2023-10-23 15:17:29 +00:00
31c68b6041 build(deps): bump @types/semver from 7.5.3 to 7.5.4 (#882) 2023-10-23 17:00:58 +02:00
d27d0c27ac build(deps-dev): bump eslint from 8.51.0 to 8.52.0 (#881) 2023-10-23 17:00:36 +02:00
4b1e98b37d build(deps): bump undici from 5.25.4 to 5.26.3 (#879)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2023-10-16 21:48:18 +02:00
5a72764667 build(deps): bump @actions/github from 5.1.1 to 6.0.0 (#877)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2023-10-16 19:37:34 +00:00
30416f05a0 build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.7.4 to 6.7.5 (#878) 2023-10-16 16:45:23 +02:00
a555e8cdd0 build(deps-dev): bump eslint-plugin-prettier from 5.0.0 to 5.0.1 (#876) 2023-10-16 11:24:49 +02:00
c8710f274e build(deps): bump @types/node from 20.8.3 to 20.8.6 (#875) 2023-10-16 11:24:31 +02:00
40776d7557 build(deps-dev): bump @typescript-eslint/parser from 6.7.4 to 6.7.5 (#874) 2023-10-16 11:24:12 +02:00
9cb5ef734c build(deps): bump @actions/http-client from 2.1.1 to 2.2.0 (#872)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2023-10-09 17:33:19 +02:00
62f96762dd build(deps-dev): bump eslint from 8.50.0 to 8.51.0 (#871) 2023-10-09 14:21:36 +02:00
84072ff78e build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.7.3 to 6.7.4 (#870) 2023-10-09 14:21:22 +02:00
a625c15a6b build(deps): bump @types/node from 20.8.0 to 20.8.3 (#869) 2023-10-09 11:34:09 +02:00
5545aac6a3 build(deps-dev): bump @typescript-eslint/parser from 6.7.3 to 6.7.4 (#868) 2023-10-09 11:33:45 +02:00
e09eda33b5 build(deps-dev): bump @typescript-eslint/parser from 6.7.2 to 6.7.3 (#866) 2023-10-02 16:11:17 +02:00
526ce234e5 build(deps): bump @types/node from 20.6.5 to 20.8.0 (#867) 2023-10-02 16:11:06 +02:00
507ec96a74 build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.7.2 to 6.7.3 (#865) 2023-10-02 15:52:22 +02:00
252bd8e8ba build(deps): bump @types/semver from 7.5.2 to 7.5.3 (#864) 2023-10-02 15:52:13 +02:00
07341d3490 build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.7.0 to 6.7.2 (#862) 2023-09-25 16:17:19 +02:00
9df6f480ac build(deps-dev): bump @typescript-eslint/parser from 6.6.0 to 6.7.2 (#861) 2023-09-25 14:39:54 +02:00
6f4d254d44 build(deps): bump @types/node from 20.6.2 to 20.6.5 (#860) 2023-09-25 14:39:33 +02:00
a24255b274 build(deps-dev): bump eslint from 8.49.0 to 8.50.0 (#859) 2023-09-25 14:39:12 +02:00
c12092e88f build(deps): bump @actions/core from 1.10.0 to 1.10.1 (#856)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2023-09-18 20:14:17 +00:00
031ba7f7a9 build(deps): bump @types/node from 20.6.0 to 20.6.2 (#857) 2023-09-18 15:29:56 +02:00
c8d4ef2f53 build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.6.0 to 6.7.0 (#855) 2023-09-18 15:29:41 +02:00
31c1b1aa98 build(deps): bump @types/tmp from 0.2.3 to 0.2.4 (#854) 2023-09-18 15:29:31 +02:00
31eb4eaded build(deps): bump @types/semver from 7.5.1 to 7.5.2 (#853) 2023-09-18 14:15:38 +02:00
5f5f252fe2 build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.5.0 to 6.6.0 (#849) 2023-09-11 10:43:57 +00:00
c624d54a53 build(deps-dev): bump @vercel/ncc from 0.36.1 to 0.38.0 (#850) 2023-09-11 10:36:27 +00:00
d735dc073f build(deps-dev): bump @typescript-eslint/parser from 6.5.0 to 6.6.0 (#848) 2023-09-11 12:21:19 +02:00
846e7ddcd9 build(deps): bump @types/node from 20.5.9 to 20.6.0 (#847) 2023-09-11 12:21:00 +02:00
d66278f1e9 build(deps-dev): bump eslint from 8.48.0 to 8.49.0 (#846) 2023-09-11 12:20:39 +02:00
1afd74ce23 build(deps): bump actions/checkout from 3 to 4 (#845) 2023-09-11 12:20:16 +02:00
c67416616c chore: bump to use node20 runtime, actions/checkout to v4 (#843) 2023-09-06 00:25:15 +00:00
29052a94fb build(deps): bump @types/node from 20.5.7 to 20.5.9 (#841) 2023-09-04 17:12:18 +02:00
2d06cf1746 build(deps-dev): bump @typescript-eslint/parser from 6.4.1 to 6.5.0 (#840) 2023-09-04 17:12:08 +02:00
953db97e74 build(deps-dev): bump prettier from 3.0.2 to 3.0.3 (#842) 2023-09-04 15:04:52 +02:00
f7b4bdd2ad build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.4.1 to 6.5.0 (#839) 2023-09-04 15:04:28 +02:00
239c8dab36 build(deps): bump @types/semver from 7.5.0 to 7.5.1 (#838) 2023-09-04 15:04:16 +02:00
237bd9f909 build(deps-dev): bump typescript from 5.1.6 to 5.2.2 (#836) 2023-08-28 12:56:19 +02:00
fef6a0f2be build(deps-dev): bump eslint from 8.47.0 to 8.48.0 (#837) 2023-08-28 12:56:03 +02:00
2d891f879c build(deps-dev): bump @typescript-eslint/parser from 6.4.0 to 6.4.1 (#835) 2023-08-28 10:20:25 +00:00
1e9c424622 build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.4.0 to 6.4.1 (#834) 2023-08-28 12:11:09 +02:00
cf670955c6 build(deps): bump @types/node from 20.5.1 to 20.5.7 (#833) 2023-08-28 09:55:58 +00:00
c49c2afa5d build(deps-dev): bump prettier from 3.0.1 to 3.0.2 (#828) 2023-08-22 22:23:22 +02:00
81871bcfd1 build(deps-dev): bump @typescript-eslint/parser from 6.3.0 to 6.4.0 (#831) 2023-08-22 22:22:46 +02:00
b2f426ba19 build(deps): bump @types/node from 20.5.0 to 20.5.1 (#827) 2023-08-21 12:29:44 +02:00
f8a3dc114e build(deps-dev): bump eslint-plugin-import from 2.28.0 to 2.28.1 (#830) 2023-08-21 12:29:23 +02:00
1330ad3e73 build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.3.0 to 6.4.0 (#829) 2023-08-21 12:29:02 +02:00
6efbbade29 docs: update examples (#826) 2023-08-18 12:56:11 +02:00
3a91952989 feat: working-directory with only-new-issues (#795)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2023-08-14 23:13:33 +02:00
5e676315e9 build(deps): bump @actions/cache from 3.2.1 to 3.2.2 (#825)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2023-08-14 14:11:19 +00:00
18dad33d2e build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.2.1 to 6.3.0 (#822) 2023-08-14 13:10:54 +02:00
945dc98b91 build(deps): bump @types/node from 20.4.8 to 20.5.0 (#824) 2023-08-14 12:52:49 +02:00
cac24f53b7 build(deps-dev): bump eslint from 8.45.0 to 8.47.0 (#823) 2023-08-14 12:52:29 +02:00
ab66454db6 build(deps-dev): bump @typescript-eslint/parser from 6.2.0 to 6.3.0 (#821) 2023-08-14 12:52:04 +02:00
a2527500a4 build(deps): bump @actions/http-client from 2.1.0 to 2.1.1 (#819) 2023-08-07 21:35:27 +00:00
44d9998d44 build(deps-dev): bump eslint-config-prettier from 8.9.0 to 9.0.0 (#818) 2023-08-07 11:54:15 +02:00
b6bdfb3d14 build(deps-dev): bump prettier from 3.0.0 to 3.0.1 (#817) 2023-08-07 11:53:50 +02:00
c0cd965566 build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.2.0 to 6.2.1 (#816) 2023-08-07 11:53:26 +02:00
66268c5fbe build(deps): bump @types/node from 20.4.5 to 20.4.8 (#815) 2023-08-07 11:53:08 +02:00
2ab8c4423e build(deps-dev): bump @typescript-eslint/parser from 6.1.0 to 6.2.0 (#812) 2023-07-31 13:48:18 +02:00
2c52863893 build(deps-dev): bump eslint-config-prettier from 8.8.0 to 8.9.0 (#811) 2023-07-31 13:47:58 +02:00
77db3f966c build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.1.0 to 6.2.0 (#810) 2023-07-31 12:44:38 +02:00
797977b61a build(deps): bump @types/node from 20.4.4 to 20.4.5 (#809) 2023-07-31 12:44:15 +02:00
015f418198 build(deps-dev): bump eslint-plugin-import from 2.27.5 to 2.28.0 (#808) 2023-07-31 12:43:55 +02:00
88ae11c65f build(deps-dev): bump @typescript-eslint/parser from 6.0.0 to 6.1.0 (#805) 2023-07-24 13:37:35 +02:00
51e800db2c build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.0.0 to 6.1.0 (#804) 2023-07-24 13:22:06 +02:00
f05002851f build(deps): bump @types/node from 20.4.2 to 20.4.4 (#803) 2023-07-24 13:10:24 +02:00
b39364735e build(deps-dev): bump @typescript-eslint/eslint-plugin from 5.61.0 to 6.0.0 (#800)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2023-07-24 13:10:01 +02:00
a657dba833 build(deps-dev): bump eslint from 8.44.0 to 8.45.0 (#801) 2023-07-17 12:50:38 +02:00
ba65924209 build(deps-dev): bump @typescript-eslint/parser from 5.61.0 to 5.62.0 (#799) 2023-07-17 12:50:09 +02:00
c0edea7835 build(deps): bump @types/node from 20.4.1 to 20.4.2 (#798) 2023-07-17 12:49:43 +02:00
a1145a6b27 build(deps-dev): bump prettier from 2.8.8 to 3.0.0 (#794)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2023-07-11 10:25:55 +02:00
83e5ccebf6 chore: flag dist as generated 2023-07-11 10:12:11 +02:00
8457318a42 build(deps): bump semver from 6.3.0 to 6.3.1 (#796)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2023-07-11 08:10:27 +00:00
a422a812eb build(deps-dev): bump @typescript-eslint/eslint-plugin from 5.60.1 to 5.61.0 (#793) 2023-07-10 12:40:10 +02:00
84836b13d8 build(deps-dev): bump @typescript-eslint/parser from 5.60.1 to 5.61.0 (#792) 2023-07-10 12:18:16 +02:00
360e5b76ee build(deps): bump @types/node from 20.3.3 to 20.4.1 (#791) 2023-07-10 12:17:51 +02:00
42ba3c24d6 build(deps): bump tough-cookie and @azure/ms-rest-js (#790) 2023-07-09 13:04:43 +02:00
4f5a3af221 build(deps-dev): bump eslint from 8.43.0 to 8.44.0 (#788) 2023-07-03 14:30:48 +02:00
f1690ab489 build(deps-dev): bump typescript from 5.1.3 to 5.1.6 (#787) 2023-07-03 14:15:42 +02:00
98d324947b build(deps-dev): bump @typescript-eslint/eslint-plugin from 5.60.0 to 5.60.1 (#786) 2023-07-03 14:15:16 +02:00
5326fa0045 build(deps-dev): bump @typescript-eslint/parser from 5.60.0 to 5.60.1 (#785) 2023-07-03 13:49:40 +02:00
4d9aae64da build(deps): bump @types/node from 20.3.1 to 20.3.3 (#784) 2023-07-03 13:49:17 +02:00
d29c0cc90a build(deps-dev): bump @typescript-eslint/parser from 5.59.11 to 5.60.0 (#783) 2023-06-26 14:05:38 +00:00
28fa3382e3 build(deps-dev): bump @typescript-eslint/eslint-plugin from 5.59.11 to 5.60.0 (#782) 2023-06-26 13:37:32 +02:00
715abd3467 docs: improve How to use section in README.md (#780) 2023-06-24 11:02:32 +00:00
01827479ce build(deps-dev): bump @typescript-eslint/eslint-plugin from 5.59.9 to 5.59.11 (#778) 2023-06-19 12:32:48 +00:00
05fe2da5ec build(deps): bump @types/node from 20.3.0 to 20.3.1 (#777) 2023-06-19 14:20:36 +02:00
2a20098909 build(deps-dev): bump eslint from 8.42.0 to 8.43.0 (#775) 2023-06-19 14:20:27 +02:00
71a9ad5faf build(deps-dev): bump @typescript-eslint/parser from 5.59.9 to 5.59.11 (#776) 2023-06-19 14:20:18 +02:00
b814b8606f chore: flag dist as generated 2023-06-13 11:28:19 +02:00
455ad55fab docs: improve changelog 2023-06-12 20:11:09 +02:00
cde40a3b90 docs: fix default value 2023-06-12 20:07:33 +02:00
444727df93 chore: exclude dependencies PRs from changelog 2023-06-12 19:29:58 +02:00
aca98fe711 chore: exclude dependabot from changelog 2023-06-12 19:22:53 +02:00
8078b42bbd docs: improve version description 2023-06-12 16:12:46 +02:00
1577f9c80c build(deps-dev): bump @typescript-eslint/eslint-plugin from 5.59.8 to 5.59.9 (#773) 2023-06-12 10:22:58 +00:00
313d11ed7d build(deps-dev): bump @typescript-eslint/parser from 5.59.8 to 5.59.9 (#772) 2023-06-12 12:14:22 +02:00
907f20a45e build(deps): bump @types/node from 20.2.5 to 20.3.0 (#771) 2023-06-12 12:14:13 +02:00
639cd343e1 tests: increase timeout 2023-06-12 11:42:49 +02:00
569abaa281 fix: out-format (#770) 2023-06-12 11:41:42 +02:00
c57cc43669 build(deps-dev): bump typescript from 5.0.4 to 5.1.3 (#764)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2023-06-12 08:57:34 +00:00
322510a3ea feat: support out-format as args (#769)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2023-06-12 10:43:54 +02:00
185e7a2f8f feat: add install-mode (#768) 2023-06-11 19:16:14 +02:00
5be60c708e docs: improve args examples 2023-06-11 17:25:06 +02:00
825a50d3a2 chore: update workflow and doc 2023-06-09 15:02:04 +02:00
8c13ec4e5d doc: Add custom configuration file path to args (#767) 2023-06-08 14:39:08 +00:00
416b5d0b48 build(deps-dev): bump @typescript-eslint/parser from 5.59.7 to 5.59.8 (#765) 2023-06-05 19:41:18 +02:00
66a608006f build(deps-dev): bump @typescript-eslint/eslint-plugin from 5.59.7 to 5.59.8 (#763) 2023-06-05 14:08:23 +02:00
f0ba586c1f build(deps-dev): bump eslint from 8.41.0 to 8.42.0 (#766) 2023-06-05 12:57:23 +02:00
b8fff06a27 docs: fix example (#762) 2023-06-03 13:06:05 +00:00
19 changed files with 56871 additions and 9465 deletions

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
dist/** linguist-generated=true

15
.github/release.yml vendored Normal file
View File

@ -0,0 +1,15 @@
changelog:
categories:
- title: Changes
labels:
- '*'
exclude:
labels:
- documentation
- dependencies
- title: Documentation
labels:
- documentation
- title: Dependencies
labels:
- dependencies

View File

@ -16,7 +16,7 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
# Must fetch at least the immediate parents so that if this is # Must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head of the pull request. # a pull request then we can checkout the head of the pull request.
@ -31,7 +31,7 @@ jobs:
# 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
# Override language selection by uncommenting this and choosing your languages # Override language selection by uncommenting this and choosing your languages
with: with:
language: 'javascript' language: 'javascript'
@ -41,4 +41,4 @@ jobs:
npm run all npm run all
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2 uses: github/codeql-action/analyze@v3

View File

@ -11,9 +11,9 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- if: ${{ !(github.event_name == 'pull_request' && (github.event.pull_request.user.id == 49699333 || contains(github.event.pull_request.labels.*.name, 'dependencies'))) }} - if: ${{ !(github.event_name == 'pull_request' && (github.event.pull_request.user.id == 49699333 || contains(github.event.pull_request.labels.*.name, 'dependencies'))) }}
uses: actions/checkout@v3 uses: actions/checkout@v4
- if: github.event_name == 'pull_request' && (github.event.pull_request.user.id == 49699333 || contains(github.event.pull_request.labels.*.name, 'dependencies')) - if: github.event_name == 'pull_request' && (github.event.pull_request.user.id == 49699333 || contains(github.event.pull_request.labels.*.name, 'dependencies'))
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }} ref: ${{ github.event.pull_request.head.ref }}
@ -52,23 +52,52 @@ jobs:
version: version:
- "" - ""
- "latest" - "latest"
- "v1.51" - "v1.58"
- "v1.51.2" - "v1.58.0"
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
permissions: permissions:
contents: read contents: read
pull-requests: read pull-requests: read
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: actions/setup-go@v4 - uses: actions/setup-go@v5
with: with:
cache: false # setup-go v4 caches by default go-version: oldstable
- uses: ./ - uses: ./
with: with:
version: ${{ matrix.version }} version: ${{ matrix.version }}
args: --timeout=3m --issues-exit-code=0 ./sample/... args: --timeout=5m --issues-exit-code=0 ./sample/...
only-new-issues: true only-new-issues: true
test-go-install: # make sure the action works on a clean machine without building (go-install mode)
needs: [ build ]
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
version:
- ""
- "latest"
- "v1.58.0"
- "4bf574a12bb61234e28e3d6172be6ed95b0e8baf"
runs-on: ${{ matrix.os }}
permissions:
contents: read
pull-requests: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: oldstable
- uses: ./
with:
version: ${{ matrix.version }}
args: --timeout=5m --issues-exit-code=0 ./sample/...
only-new-issues: true
install-mode: goinstall
test-go-mod-version: test-go-mod-version:
needs: [ build ] needs: [ build ]
strategy: strategy:
@ -81,11 +110,11 @@ jobs:
permissions: permissions:
contents: read contents: read
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: actions/setup-go@v4 - uses: actions/setup-go@v5
with: with:
cache: false # setup-go v4 caches by default go-version: oldstable
- uses: ./ - uses: ./
with: with:
working-directory: sample-go-mod working-directory: sample-go-mod
args: --timeout=3m --issues-exit-code=0 ./... args: --timeout=5m --issues-exit-code=0 ./...

3
.gitignore vendored
View File

@ -97,3 +97,6 @@ typings/
# Text editor files # Text editor files
.vscode/ .vscode/
# IntelliJ/WebStorm files
.idea

280
README.md
View File

@ -3,13 +3,15 @@
[![Build Status](https://github.com/golangci/golangci-lint-action/workflows/build-and-test/badge.svg)](https://github.com/golangci/golangci-lint-action/actions) [![Build Status](https://github.com/golangci/golangci-lint-action/workflows/build-and-test/badge.svg)](https://github.com/golangci/golangci-lint-action/actions)
It's the official GitHub action for [golangci-lint](https://github.com/golangci/golangci-lint) from its authors. It's the official GitHub action for [golangci-lint](https://github.com/golangci/golangci-lint) from its authors.
The action runs [golangci-lint](https://github.com/golangci/golangci-lint) and reports issues from linters. The action runs [golangci-lint](https://github.com/golangci/golangci-lint) and reports issues from linters.
![GitHub Annotations](./static/annotations.png) ![GitHub Annotations](./static/annotations.png)
## Compatibility ## Compatibility
* `v3.0.0+` requires explicit setup-go installation step prior to using this action: `uses: actions/setup-go@v3`. * `v5.0.0+` removes `skip-pkg-cache` and `skip-build-cache` because the cache related to Go itself is already handled by `actions/setup-go`.
* `v4.0.0+` requires an explicit `actions/setup-go` installation step before using this action: `uses: actions/setup-go@v5`.
The `skip-go-installation` option has been removed. The `skip-go-installation` option has been removed.
* `v2.0.0+` works with `golangci-lint` version >= `v1.28.3` * `v2.0.0+` works with `golangci-lint` version >= `v1.28.3`
* `v1.2.2` is deprecated due to we forgot to change the minimum version of `golangci-lint` to `v1.28.3` ([issue](https://github.com/golangci/golangci-lint-action/issues/39)) * `v1.2.2` is deprecated due to we forgot to change the minimum version of `golangci-lint` to `v1.28.3` ([issue](https://github.com/golangci/golangci-lint-action/issues/39))
@ -23,124 +25,259 @@ Add `.github/workflows/golangci-lint.yml` with the following contents:
name: golangci-lint name: golangci-lint
on: on:
push: push:
tags:
- v*
branches: branches:
- master
- main - main
- master
pull_request: pull_request:
permissions: permissions:
contents: read contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option. # Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read # pull-requests: read
jobs: jobs:
golangci: golangci:
name: lint name: lint
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/setup-go@v4 - uses: actions/checkout@v4
- uses: actions/setup-go@v5
with: with:
go-version: '1.17' go-version: '1.22'
cache: false
- uses: actions/checkout@v3
- name: golangci-lint - name: golangci-lint
uses: golangci/golangci-lint-action@v3 uses: golangci/golangci-lint-action@v5
with: with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version version: latest
version: v1.29
# Optional: working directory, useful for monorepos
# working-directory: somedir
# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0
# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true
# Optional: if set to true then the all caching functionality will be complete disabled,
# takes precedence over all other caching options.
# skip-cache: true
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
``` ```
We recommend running this action in a job separate from other jobs (`go test`, etc) We recommend running this action in a job separate from other jobs (`go test`, etc.)
because different jobs [run in parallel](https://help.github.com/en/actions/getting-started-with-github-actions/core-concepts-for-github-actions#job). because different jobs [run in parallel](https://help.github.com/en/actions/getting-started-with-github-actions/core-concepts-for-github-actions#job).
### Multiple OS Support ### Multiple OS Support
If you need to run linters for specific operating systems, you will need to use `v2` of the action. Here is a sample configuration file: If you need to run linters for specific operating systems, you will need to use the action `>=v2`.
Here is a sample configuration file:
```yaml ```yaml
name: golangci-lint name: golangci-lint
on: on:
push: push:
tags:
- v*
branches: branches:
- master
- main - main
- master
pull_request: pull_request:
permissions: permissions:
contents: read contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option. # Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read # pull-requests: read
jobs: jobs:
golangci: golangci:
strategy: strategy:
matrix: matrix:
go: [1.17] go: ['1.22']
os: [macos-latest, windows-latest] os: [ubuntu-latest, macos-latest, windows-latest]
name: lint name: lint
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: actions/setup-go@v4 - uses: actions/setup-go@v5
with: with:
go-version: ${{ matrix.go }} go-version: ${{ matrix.go }}
cache: false
- name: golangci-lint - name: golangci-lint
uses: golangci/golangci-lint-action@v3 uses: golangci/golangci-lint-action@v5
with: with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. version: latest
version: v1.29
# Optional: working directory, useful for monorepos
# working-directory: somedir
# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0
# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true
``` ```
You will also likely need to add the following `.gitattributes` file to ensure that line endings for windows builds are properly formatted: You will also likely need to add the following `.gitattributes` file to ensure that line endings for Windows builds are properly formatted:
```.gitattributes ```.gitattributes
*.go text eol=lf *.go text eol=lf
``` ```
## Comments and Annotations ## Options
Currently, GitHub parses the action's output and creates [annotations](https://github.community/t5/GitHub-Actions/What-are-annotations/td-p/30770). ### `version`
(required)
The version of golangci-lint to use.
* When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
* When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
```yml
uses: golangci/golangci-lint-action@v5
with:
version: latest
# ...
```
### `install-mode`
(optional)
The mode to install golangci-lint: it can be `binary` or `goinstall`.
The default value is `binary`.
```yml
uses: golangci/golangci-lint-action@v5
with:
install-mode: "goinstall"
# ...
```
### `only-new-issues`
(optional)
Show only new issues.
The default value is `false`.
```yml
uses: golangci/golangci-lint-action@v5
with:
only-new-issues: true
# ...
```
* `pull_request` and `pull_request_target`: the action gets the diff of the PR content from the [GitHub API](https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#get-a-pull-request) and use it with `--new-from-patch`.
* `push`: the action gets the diff of the push content (difference between commits before and after the push) from the [GitHub API](https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#compare-two-commits) and use it with `--new-from-patch`.
* `merge_group`: the action gets the diff by using `--new-from-rev` option (relies on git).
You should add the option `fetch-depth: 0` to `actions/checkout` step.
### `working-directory`
(optional)
Working directory, useful for monorepos.
```yml
uses: golangci/golangci-lint-action@v5
with:
working-directory: somedir
# ...
```
### `skip-cache`
(optional)
If set to `true`, then all caching functionality will be completely disabled,
takes precedence over all other caching options.
The default value is `false`.
```yml
uses: golangci/golangci-lint-action@v5
with:
skip-cache: true
# ...
```
### `skip-save-cache`
(optional)
If set to `true`, caches will not be saved, but they may still be restored, required `skip-cache: false`.
The default value is `false`.
```yml
uses: golangci/golangci-lint-action@v5
with:
skip-save-cache: true
# ...
```
### `cache-invalidation-interval`
(optional)
Periodically invalidate the cache every `cache-invalidation-interval` days to ensure that outdated data is removed and fresh data is loaded.
The default value is `7`.
```yml
uses: golangci/golangci-lint-action@v5
with:
cache-invalidation-interval: 15
# ...
```
If set the number is `<= 0`, the cache will be always invalidate (Not recommended).
### `annotations`
(optional)
To enable/disable GitHub Action annotations.
If disabled (`false`), the output format(s) will follow the golangci-lint configuration file (or CLI flags from `args`)
and use the same default as golangci-lint (i.e. `colored-line-number`).
https://golangci-lint.run/usage/configuration/#output-configuration
The default value is `true`.
```yml
uses: golangci/golangci-lint-action@v5
with:
annotations: false
# ...
```
### `args`
(optional)
golangci-lint command line arguments.
Note: By default, the `.golangci.yml` file should be at the root of the repository.
The location of the configuration file can be changed by using `--config=`
```yml
uses: golangci/golangci-lint-action@v5
with:
args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0
# ...
```
## Annotations
Currently, GitHub parses the action's output and creates [annotations](https://github.blog/2018-12-14-introducing-check-runs-and-annotations/).
The restrictions of annotations are the following: The restrictions of annotations are the following:
1. Currently, they don't support markdown formatting (see the [feature request](https://github.community/t5/GitHub-API-Development-and/Checks-Ability-to-include-Markdown-in-line-annotations/m-p/56704)) 1. Currently, they don't support Markdown formatting (see the [feature request](https://github.community/t5/GitHub-API-Development-and/Checks-Ability-to-include-Markdown-in-line-annotations/m-p/56704))
2. They aren't shown in list of comments like it was with [golangci.com](https://golangci.com). If you would like to have comments - please, up-vote [the issue](https://github.com/golangci/golangci-lint-action/issues/5). 2. They aren't shown in the list of comments.
If you would like to have comments - please, up-vote [the issue](https://github.com/golangci/golangci-lint-action/issues/5).
3. The number of annotations is [limited](https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md#limitations).
To enable annotations, you need to add the `checks` permission to your action.
```yaml annotate
permissions:
# Required: allow read access to the content for analysis.
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
pull-requests: read
# Optional: allow write access to checks to allow the action to annotate code in the PR.
checks: write
```
## Performance ## Performance
The action was implemented with performance in mind: The action was implemented with performance in mind:
1. We cache data by [@actions/cache](https://github.com/actions/toolkit/tree/master/packages/cache) between builds: Go build cache, Go modules cache, golangci-lint analysis cache. 1. We cache data from golangci-lint analysis between builds by using [@actions/cache](https://github.com/actions/toolkit/tree/master/packages/cache).
2. We don't use Docker because image pulling is slow. 2. We don't use Docker because image pulling is slow.
3. We do as much as we can in parallel, e.g. we download cache, go and golangci-lint binary in parallel. 3. We do as much as we can in parallel, e.g. we download cache, and golangci-lint binary in parallel.
For example, in a repository of [golangci-lint](https://github.com/golangci/golangci-lint) running this action without the cache takes 50s, but with cache takes 14s: For example, in a repository of [golangci-lint](https://github.com/golangci/golangci-lint) running this action without the cache takes 50s, but with cache takes 14s:
* in parallel: * in parallel:
@ -150,28 +287,33 @@ For example, in a repository of [golangci-lint](https://github.com/golangci/gola
## Internals ## Internals
We use JavaScript-based action. We don't use Docker-based action because: We use JavaScript-based action.
We don't use Docker-based action because:
1. docker pulling is slow currently 1. Docker pulling is slow currently
2. it's easier to use caching from [@actions/cache](https://github.com/actions/toolkit/tree/master/packages/cache) 2. it's easier to use caching from [@actions/cache](https://github.com/actions/toolkit/tree/master/packages/cache)
We support different platforms, such as `ubuntu`, `macos` and `windows` with `x32` and `x64` archs. We support different platforms, such as `ubuntu`, `macos`, and `windows` with `x32` and `x64` archs.
Inside our action we perform 3 steps: Inside our action, we perform 3 steps:
1. Setup environment running in parallel: 1. Setup environment running in parallel:
* restore [cache](https://github.com/actions/cache) of previous analyzes * restore [cache](https://github.com/actions/cache) of previous analyses
* fetch [action config](https://github.com/golangci/golangci-lint/blob/master/assets/github-action-config.json) and find the latest `golangci-lint` patch version * fetch [action config](https://github.com/golangci/golangci-lint/blob/master/assets/github-action-config.json) and find the latest `golangci-lint` patch version for needed version
for needed version (users of this action can specify only minor version of `golangci-lint`). After that install [golangci-lint](https://github.com/golangci/golangci-lint) using [@actions/tool-cache](https://github.com/actions/toolkit/tree/master/packages/tool-cache) (users of this action can specify only minor version of `golangci-lint`).
After that install [golangci-lint](https://github.com/golangci/golangci-lint) using [@actions/tool-cache](https://github.com/actions/toolkit/tree/master/packages/tool-cache)
2. Run `golangci-lint` with specified by user `args` 2. Run `golangci-lint` with specified by user `args`
3. Save cache for later builds 3. Save cache for later builds
### Caching internals ### Caching internals
1. We save and restore the following directories: `~/.cache/golangci-lint`, `~/.cache/go-build`, `~/go/pkg`. 1. We save and restore the following directory: `~/.cache/golangci-lint`.
2. The primary caching key looks like `golangci-lint.cache-{interval_number}-{go.mod_hash}`. Interval number ensures that we periodically invalidate 2. The primary caching key looks like `golangci-lint.cache-{runner_os}-{working_directory}-{interval_number}-{go.mod_hash}`.
our cache (every 7 days). `go.mod` hash ensures that we invalidate the cache early - as soon as dependencies have changed. Interval number ensures that we periodically invalidate our cache (every 7 days).
3. We use [restore keys](https://help.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key): `golangci-lint.cache-{interval_number}-`. GitHub matches keys by prefix if we have no exact match for the primary cache. `go.mod` hash ensures that we invalidate the cache early - as soon as dependencies have changed.
3. We use [restore keys](https://help.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key):
`golangci-lint.cache-{runner_os}-{working_directory}-{interval_number}-`.
GitHub matches keys by prefix if we have no exact match for the primary cache.
This scheme is basic and needs improvements. Pull requests and ideas are welcome. This scheme is basic and needs improvements. Pull requests and ideas are welcome.

View File

@ -1,13 +1,17 @@
name: "Run golangci-lint" # https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions
name: "Golangci-lint"
description: "Official golangci-lint action with line-attached annotations for found issues, caching and parallel execution." description: "Official golangci-lint action with line-attached annotations for found issues, caching and parallel execution."
author: "golangci" author: "golangci"
inputs: inputs:
version: version:
description: "version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version" description: |
The version of golangci-lint to use.
When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
required: false required: false
args: install-mode:
description: "golangci-lint command line arguments" description: "The mode to install golangci-lint. It can be 'binary' or 'goinstall'."
default: "" default: "binary"
required: false required: false
working-directory: working-directory:
description: "golangci-lint working directory, default is project root" description: "golangci-lint working directory, default is project root"
@ -18,26 +22,36 @@ inputs:
required: false required: false
only-new-issues: only-new-issues:
description: "if set to true and the action runs on a pull request - the action outputs only newly found issues" description: "if set to true and the action runs on a pull request - the action outputs only newly found issues"
default: false default: 'false'
required: false required: false
skip-cache: skip-cache:
description: | description: |
if set to true then the all caching functionality will be complete disabled, if set to true then the all caching functionality will be complete disabled,
takes precedence over all other caching options. takes precedence over all other caching options.
default: false default: 'false'
required: false required: false
skip-pkg-cache: skip-save-cache:
description: "if set to true then the action doesn't cache or restore ~/go/pkg." description: |
default: false if set to true then the action will not save any caches, but it may still
restore existing caches, subject to other options.
default: 'false'
required: false required: false
skip-build-cache: annotations:
description: "if set to true then the action doesn't cache or restore ~/.cache/go-build." description: "To Enable/disable GitHub Action annotations"
default: false default: 'true'
required: false
args:
description: "golangci-lint command line arguments"
default: ""
required: false
cache-invalidation-interval:
description: "Periodically invalidate a cache because a new code being added. (number of days)"
default: '7'
required: false required: false
runs: runs:
using: "node16" using: "node20"
main: "dist/run/index.js" main: "dist/run/index.js"
post: "dist/post_run/index.js" post: "dist/post_run/index.js"
branding: branding:
icon: "shield" icon: "shield"
color: "yellow" color: "white"

31086
dist/post_run/index.js generated vendored

File diff suppressed because one or more lines are too long

31086
dist/run/index.js generated vendored

File diff suppressed because one or more lines are too long

3314
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -24,27 +24,27 @@
"author": "golangci", "author": "golangci",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/cache": "^3.2.1", "@actions/cache": "^3.2.4",
"@actions/core": "^1.10.0", "@actions/core": "^1.10.1",
"@actions/exec": "^1.1.1", "@actions/exec": "^1.1.1",
"@actions/github": "^5.1.1", "@actions/github": "^6.0.0",
"@actions/http-client": "^2.1.0", "@actions/http-client": "^2.2.1",
"@actions/tool-cache": "^2.0.1", "@actions/tool-cache": "^2.0.1",
"@types/node": "^20.2.5", "@types/node": "^20.12.7",
"@types/semver": "^7.5.0", "@types/semver": "^7.5.8",
"@types/tmp": "^0.2.3", "@types/tmp": "^0.2.6",
"tmp": "^0.2.1" "tmp": "^0.2.3"
}, },
"devDependencies": { "devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.59.7", "@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^5.59.7", "@typescript-eslint/parser": "^7.7.1",
"@vercel/ncc": "^0.36.1", "@vercel/ncc": "^0.38.1",
"eslint": "^8.41.0", "eslint": "^8.57.0",
"eslint-config-prettier": "^8.8.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.27.5", "eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-simple-import-sort": "^10.0.0", "eslint-plugin-simple-import-sort": "^12.1.0",
"prettier": "^2.8.8", "prettier": "^3.2.5",
"typescript": "^5.0.4" "typescript": "^5.4.5"
} }
} }

View File

@ -167,7 +167,7 @@ require (
golang.org/x/sys v0.5.0 // indirect golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.6.0 // indirect golang.org/x/text v0.6.0 // indirect
golang.org/x/tools v0.6.0 // indirect golang.org/x/tools v0.6.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect

View File

@ -924,8 +924,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

View File

@ -23,28 +23,13 @@ const getLintCacheDir = (): string => {
return path.resolve(`${process.env.HOME}/.cache/golangci-lint`) return path.resolve(`${process.env.HOME}/.cache/golangci-lint`)
} }
const getCacheDirs = (): string[] => {
// Not existing dirs are ok here: it works.
const skipPkgCache = core.getInput(`skip-pkg-cache`, { required: true }).trim()
const skipBuildCache = core.getInput(`skip-build-cache`, { required: true }).trim()
const dirs = [getLintCacheDir()]
if (skipBuildCache.toLowerCase() == "true") {
core.info(`Omitting ~/.cache/go-build from cache directories`)
} else {
dirs.push(path.resolve(`${process.env.HOME}/.cache/go-build`))
}
if (skipPkgCache.toLowerCase() == "true") {
core.info(`Omitting ~/go/pkg from cache directories`)
} else {
dirs.push(path.resolve(`${process.env.HOME}/go/pkg`))
}
return dirs
}
const getIntervalKey = (invalidationIntervalDays: number): string => { const getIntervalKey = (invalidationIntervalDays: number): string => {
const now = new Date() const now = new Date()
if (invalidationIntervalDays <= 0) {
return `${now.getTime()}`
}
const secondsSinceEpoch = now.getTime() / 1000 const secondsSinceEpoch = now.getTime() / 1000
const intervalNumber = Math.floor(secondsSinceEpoch / (invalidationIntervalDays * 86400)) const intervalNumber = Math.floor(secondsSinceEpoch / (invalidationIntervalDays * 86400))
return intervalNumber.toString() return intervalNumber.toString()
@ -52,28 +37,42 @@ const getIntervalKey = (invalidationIntervalDays: number): string => {
async function buildCacheKeys(): Promise<string[]> { async function buildCacheKeys(): Promise<string[]> {
const keys = [] const keys = []
// Periodically invalidate a cache because a new code being added.
// TODO: configure it via inputs. // Cache by OS.
let cacheKey = `golangci-lint.cache-${getIntervalKey(7)}-` let cacheKey = `golangci-lint.cache-${process.env?.RUNNER_OS}-`
keys.push(cacheKey)
// Get working directory from input // Get working directory from input
const workingDirectory = core.getInput(`working-directory`) const workingDirectory = core.getInput(`working-directory`)
if (workingDirectory) {
cacheKey += `${workingDirectory}-`
}
// Periodically invalidate a cache because a new code being added.
const invalidationIntervalDays = parseInt(core.getInput(`cache-invalidation-interval`, { required: true }).trim())
cacheKey += `${getIntervalKey(invalidationIntervalDays)}-`
keys.push(cacheKey)
// create path to go.mod prepending the workingDirectory if it exists // create path to go.mod prepending the workingDirectory if it exists
const goModPath = path.join(workingDirectory, `go.mod`) const goModPath = path.join(workingDirectory, `go.mod`)
core.info(`Checking for go.mod: ${goModPath}`) core.info(`Checking for go.mod: ${goModPath}`)
if (await pathExists(goModPath)) { if (await pathExists(goModPath)) {
// Add checksum to key to invalidate a cache when dependencies change. // Add checksum to key to invalidate a cache when dependencies change.
cacheKey += await checksumFile(`sha1`, goModPath) cacheKey += await checksumFile(`sha1`, goModPath)
} else { } else {
cacheKey += `nogomod` cacheKey += `nogomod`
} }
keys.push(cacheKey) keys.push(cacheKey)
return keys return keys
} }
export async function restoreCache(): Promise<void> { export async function restoreCache(): Promise<void> {
if (core.getInput(`skip-cache`, { required: true }).trim() == "true") return if (core.getBooleanInput(`skip-cache`, { required: true })) return
if (!utils.isValidEvent()) { if (!utils.isValidEvent()) {
utils.logWarning( utils.logWarning(
@ -97,7 +96,7 @@ export async function restoreCache(): Promise<void> {
} }
core.saveState(State.CachePrimaryKey, primaryKey) core.saveState(State.CachePrimaryKey, primaryKey)
try { try {
const cacheKey = await cache.restoreCache(getCacheDirs(), primaryKey, restoreKeys) const cacheKey = await cache.restoreCache([getLintCacheDir()], primaryKey, restoreKeys)
if (!cacheKey) { if (!cacheKey) {
core.info(`Cache not found for input keys: ${[primaryKey, ...restoreKeys].join(", ")}`) core.info(`Cache not found for input keys: ${[primaryKey, ...restoreKeys].join(", ")}`)
return return
@ -115,7 +114,8 @@ export async function restoreCache(): Promise<void> {
} }
export async function saveCache(): Promise<void> { export async function saveCache(): Promise<void> {
if (core.getInput(`skip-cache`, { required: true }).trim() == "true") return if (core.getBooleanInput(`skip-cache`, { required: true })) return
if (core.getBooleanInput(`skip-save-cache`, { required: true })) return
// Validate inputs, this can cause task failure // Validate inputs, this can cause task failure
if (!utils.isValidEvent()) { if (!utils.isValidEvent()) {
@ -127,7 +127,7 @@ export async function saveCache(): Promise<void> {
const startedAt = Date.now() const startedAt = Date.now()
const cacheDirs = getCacheDirs() const cacheDirs = [getLintCacheDir()]
const primaryKey = core.getState(State.CachePrimaryKey) const primaryKey = core.getState(State.CachePrimaryKey)
if (!primaryKey) { if (!primaryKey) {
utils.logWarning(`Error retrieving key from state.`) utils.logWarning(`Error retrieving key from state.`)

View File

@ -1,10 +1,14 @@
import * as core from "@actions/core" import * as core from "@actions/core"
import * as tc from "@actions/tool-cache" import * as tc from "@actions/tool-cache"
import { exec, ExecOptions } from "child_process"
import os from "os" import os from "os"
import path from "path" import path from "path"
import { promisify } from "util"
import { VersionConfig } from "./version" import { VersionConfig } from "./version"
const execShellCommand = promisify(exec)
const downloadURL = "https://github.com/golangci/golangci-lint/releases/download" const downloadURL = "https://github.com/golangci/golangci-lint/releases/download"
const getAssetURL = (versionConfig: VersionConfig): string => { const getAssetURL = (versionConfig: VersionConfig): string => {
@ -31,13 +35,95 @@ const getAssetURL = (versionConfig: VersionConfig): string => {
return `${downloadURL}/${versionConfig.TargetVersion}/golangci-lint-${noPrefix}-${platform}-${arch}.${ext}` return `${downloadURL}/${versionConfig.TargetVersion}/golangci-lint-${noPrefix}-${platform}-${arch}.${ext}`
} }
// The installLint returns path to installed binary of golangci-lint. export enum InstallMode {
export async function installLint(versionConfig: VersionConfig): Promise<string> { Binary = "binary",
GoInstall = "goinstall",
}
type ExecRes = {
stdout: string
stderr: string
}
const printOutput = (res: ExecRes): void => {
if (res.stdout) {
core.info(res.stdout)
}
if (res.stderr) {
core.info(res.stderr)
}
}
/**
* Install golangci-lint.
*
* @param versionConfig information about version to install.
* @param mode installation mode.
* @returns path to installed binary of golangci-lint.
*/
export async function installLint(versionConfig: VersionConfig, mode: InstallMode): Promise<string> {
core.info(`Installation mode: ${mode}`)
switch (mode) {
case InstallMode.Binary:
return installBin(versionConfig)
case InstallMode.GoInstall:
return goInstall(versionConfig)
default:
return installBin(versionConfig)
}
}
/**
* Install golangci-lint via `go install`.
*
* @param versionConfig information about version to install.
* @returns path to installed binary of golangci-lint.
*/
export async function goInstall(versionConfig: VersionConfig): Promise<string> {
core.info(`Installing golangci-lint ${versionConfig.TargetVersion}...`) core.info(`Installing golangci-lint ${versionConfig.TargetVersion}...`)
const startedAt = Date.now() const startedAt = Date.now()
const options: ExecOptions = { env: { ...process.env, CGO_ENABLED: "1" } }
const exres = await execShellCommand(
`go install github.com/golangci/golangci-lint/cmd/golangci-lint@${versionConfig.TargetVersion}`,
options
)
printOutput(exres)
const res = await execShellCommand(
`go install -n github.com/golangci/golangci-lint/cmd/golangci-lint@${versionConfig.TargetVersion}`,
options
)
printOutput(res)
// The output of `go install -n` when the binary is already installed is `touch <path_to_the_binary>`.
const lintPath = res.stderr.trimStart().trimEnd().split(` `, 2)[1]
core.info(`Installed golangci-lint into ${lintPath} in ${Date.now() - startedAt}ms`)
return lintPath
}
/**
* Install golangci-lint via the precompiled binary.
*
* @param versionConfig information about version to install.
* @returns path to installed binary of golangci-lint.
*/
export async function installBin(versionConfig: VersionConfig): Promise<string> {
core.info(`Installing golangci-lint binary ${versionConfig.TargetVersion}...`)
const startedAt = Date.now()
const assetURL = getAssetURL(versionConfig) const assetURL = getAssetURL(versionConfig)
core.info(`Downloading ${assetURL} ...`)
core.info(`Downloading binary ${assetURL} ...`)
const archivePath = await tc.downloadTool(assetURL) const archivePath = await tc.downloadTool(assetURL)
let extractedDir = "" let extractedDir = ""
let repl = /\.tar\.gz$/ let repl = /\.tar\.gz$/
if (assetURL.endsWith("zip")) { if (assetURL.endsWith("zip")) {
@ -55,6 +141,8 @@ export async function installLint(versionConfig: VersionConfig): Promise<string>
const urlParts = assetURL.split(`/`) const urlParts = assetURL.split(`/`)
const dirName = urlParts[urlParts.length - 1].replace(repl, ``) const dirName = urlParts[urlParts.length - 1].replace(repl, ``)
const lintPath = path.join(extractedDir, dirName, `golangci-lint`) const lintPath = path.join(extractedDir, dirName, `golangci-lint`)
core.info(`Installed golangci-lint into ${lintPath} in ${Date.now() - startedAt}ms`) core.info(`Installed golangci-lint into ${lintPath} in ${Date.now() - startedAt}ms`)
return lintPath return lintPath
} }

View File

@ -1,5 +1,6 @@
import * as core from "@actions/core" import * as core from "@actions/core"
import * as github from "@actions/github" import * as github from "@actions/github"
import { Context } from "@actions/github/lib/context"
import { exec, ExecOptions } from "child_process" import { exec, ExecOptions } from "child_process"
import * as fs from "fs" import * as fs from "fs"
import * as path from "path" import * as path from "path"
@ -7,44 +8,62 @@ import { dir } from "tmp"
import { promisify } from "util" import { promisify } from "util"
import { restoreCache, saveCache } from "./cache" import { restoreCache, saveCache } from "./cache"
import { installLint } from "./install" import { installLint, InstallMode } from "./install"
import { alterDiffPatch } from "./utils/diffUtils"
import { findLintVersion } from "./version" import { findLintVersion } from "./version"
const execShellCommand = promisify(exec) const execShellCommand = promisify(exec)
const writeFile = promisify(fs.writeFile) const writeFile = promisify(fs.writeFile)
const createTempDir = promisify(dir) const createTempDir = promisify(dir)
function isOnlyNewIssues(): boolean {
return core.getBooleanInput(`only-new-issues`, { required: true })
}
async function prepareLint(): Promise<string> { async function prepareLint(): Promise<string> {
const versionConfig = await findLintVersion() const mode = core.getInput("install-mode").toLowerCase()
return await installLint(versionConfig) const versionConfig = await findLintVersion(<InstallMode>mode)
return await installLint(versionConfig, <InstallMode>mode)
} }
async function fetchPatch(): Promise<string> { async function fetchPatch(): Promise<string> {
const onlyNewIssues = core.getInput(`only-new-issues`, { required: true }).trim() if (!isOnlyNewIssues()) {
if (onlyNewIssues !== `false` && onlyNewIssues !== `true`) {
throw new Error(`invalid value of "only-new-issues": "${onlyNewIssues}", expected "true" or "false"`)
}
if (onlyNewIssues === `false`) {
return `` return ``
} }
const ctx = github.context const ctx = github.context
if (ctx.eventName !== `pull_request`) {
core.info(`Not fetching patch for showing only new issues because it's not a pull request context: event name is ${ctx.eventName}`) switch (ctx.eventName) {
return `` case `pull_request`:
case `pull_request_target`:
return await fetchPullRequestPatch(ctx)
case `push`:
return await fetchPushPatch(ctx)
case `merge_group`:
core.info(JSON.stringify(ctx.payload))
return ``
default:
core.info(`Not fetching patch for showing only new issues because it's not a pull request context: event name is ${ctx.eventName}`)
return ``
} }
const pull = ctx.payload.pull_request }
if (!pull) {
async function fetchPullRequestPatch(ctx: Context): Promise<string> {
const pr = ctx.payload.pull_request
if (!pr) {
core.warning(`No pull request in context`) core.warning(`No pull request in context`)
return `` return ``
} }
const octokit = github.getOctokit(core.getInput(`github-token`, { required: true })) const octokit = github.getOctokit(core.getInput(`github-token`, { required: true }))
let patch: string let patch: string
try { try {
const patchResp = await octokit.rest.pulls.get({ const patchResp = await octokit.rest.pulls.get({
owner: ctx.repo.owner, owner: ctx.repo.owner,
repo: ctx.repo.repo, repo: ctx.repo.repo,
[`pull_number`]: pull.number, [`pull_number`]: pr.number,
mediaType: { mediaType: {
format: `diff`, format: `diff`,
}, },
@ -66,7 +85,45 @@ async function fetchPatch(): Promise<string> {
const tempDir = await createTempDir() const tempDir = await createTempDir()
const patchPath = path.join(tempDir, "pull.patch") const patchPath = path.join(tempDir, "pull.patch")
core.info(`Writing patch to ${patchPath}`) core.info(`Writing patch to ${patchPath}`)
await writeFile(patchPath, patch) await writeFile(patchPath, alterDiffPatch(patch))
return patchPath
} catch (err) {
console.warn(`failed to save pull request patch:`, err)
return `` // don't fail the action, but analyze without patch
}
}
async function fetchPushPatch(ctx: Context): Promise<string> {
const octokit = github.getOctokit(core.getInput(`github-token`, { required: true }))
let patch: string
try {
const patchResp = await octokit.rest.repos.compareCommitsWithBasehead({
owner: ctx.repo.owner,
repo: ctx.repo.repo,
basehead: `${ctx.payload.before}..${ctx.payload.after}`,
mediaType: {
format: `diff`,
},
})
if (patchResp.status !== 200) {
core.warning(`failed to fetch push patch: response status is ${patchResp.status}`)
return `` // don't fail the action, but analyze without patch
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
patch = patchResp.data as any
} catch (err) {
console.warn(`failed to fetch push patch:`, err)
return `` // don't fail the action, but analyze without patch
}
try {
const tempDir = await createTempDir()
const patchPath = path.join(tempDir, "push.patch")
core.info(`Writing patch to ${patchPath}`)
await writeFile(patchPath, alterDiffPatch(patch))
return patchPath return patchPath
} catch (err) { } catch (err) {
console.warn(`failed to save pull request patch:`, err) console.warn(`failed to save pull request patch:`, err)
@ -83,15 +140,13 @@ async function prepareEnv(): Promise<Env> {
const startedAt = Date.now() const startedAt = Date.now()
// Prepare cache, lint and go in parallel. // Prepare cache, lint and go in parallel.
const restoreCachePromise = restoreCache() await restoreCache()
const prepareLintPromise = prepareLint()
const patchPromise = fetchPatch()
const lintPath = await prepareLintPromise const lintPath = await prepareLint()
await restoreCachePromise const patchPath = await fetchPatch()
const patchPath = await patchPromise
core.info(`Prepared env in ${Date.now() - startedAt}ms`) core.info(`Prepared env in ${Date.now() - startedAt}ms`)
return { lintPath, patchPath } return { lintPath, patchPath }
} }
@ -116,40 +171,72 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
printOutput(res) printOutput(res)
} }
const userArgs = core.getInput(`args`) let userArgs = core.getInput(`args`)
const addedArgs: string[] = [] const addedArgs: string[] = []
const userArgNames = new Set<string>( const userArgsList = userArgs
userArgs .trim()
.trim() .split(/\s+/)
.split(/\s+/) .filter((arg) => arg.startsWith(`-`))
.map((arg) => arg.split(`=`)[0]) .map((arg) => arg.replace(/^-+/, ``))
.filter((arg) => arg.startsWith(`-`)) .map((arg) => arg.split(/=(.*)/, 2))
.map((arg) => arg.replace(/^-+/, ``)) .map<[string, string]>(([key, value]) => [key.toLowerCase(), value ?? ""])
)
if (userArgNames.has(`out-format`)) {
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`)
}
addedArgs.push(`--out-format=github-actions`)
if (patchPath) { const userArgsMap = new Map<string, string>(userArgsList)
const userArgNames = new Set<string>(userArgsList.map(([key]) => key))
const annotations = core.getBooleanInput(`annotations`)
if (annotations) {
const formats = (userArgsMap.get("out-format") || "")
.trim()
.split(",")
.filter((f) => f.length > 0)
.filter((f) => !f.startsWith(`github-actions`))
.concat("github-actions")
.join(",")
addedArgs.push(`--out-format=${formats}`)
userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim()
}
if (isOnlyNewIssues()) {
if (userArgNames.has(`new`) || userArgNames.has(`new-from-rev`) || userArgNames.has(`new-from-patch`)) { if (userArgNames.has(`new`) || userArgNames.has(`new-from-rev`) || userArgNames.has(`new-from-patch`)) {
throw new Error(`please, don't specify manually --new* args when requesting only new issues`) throw new Error(`please, don't specify manually --new* args when requesting only new issues`)
} }
addedArgs.push(`--new-from-patch=${patchPath}`)
// Override config values. const ctx = github.context
addedArgs.push(`--new=false`)
addedArgs.push(`--new-from-rev=`) core.info(`only new issues on ${ctx.eventName}: ${patchPath}`)
switch (ctx.eventName) {
case `pull_request`:
case `pull_request_target`:
case `push`:
if (patchPath) {
addedArgs.push(`--new-from-patch=${patchPath}`)
// Override config values.
addedArgs.push(`--new=false`)
addedArgs.push(`--new-from-rev=`)
}
break
case `merge_group`:
addedArgs.push(`--new-from-rev=${ctx.payload.merge_group.base_sha}`)
// Override config values.
addedArgs.push(`--new=false`)
addedArgs.push(`--new-from-patch=`)
break
default:
break
}
} }
const workingDirectory = core.getInput(`working-directory`)
const cmdArgs: ExecOptions = {} const cmdArgs: ExecOptions = {}
const workingDirectory = core.getInput(`working-directory`)
if (workingDirectory) { if (workingDirectory) {
if (patchPath) {
// TODO: make them compatible
throw new Error(`options working-directory and only-new-issues aren't compatible`)
}
if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) { if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) {
throw new Error(`working-directory (${workingDirectory}) was not a path`) throw new Error(`working-directory (${workingDirectory}) was not a path`)
} }
@ -159,8 +246,10 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
cmdArgs.cwd = path.resolve(workingDirectory) cmdArgs.cwd = path.resolve(workingDirectory)
} }
const cmd = `${lintPath} run ${addedArgs.join(` `)} ${userArgs}`.trimRight() const cmd = `${lintPath} run ${addedArgs.join(` `)} ${userArgs}`.trimEnd()
core.info(`Running [${cmd}] in [${cmdArgs.cwd || ``}] ...`)
core.info(`Running [${cmd}] in [${cmdArgs.cwd || process.cwd()}] ...`)
const startedAt = Date.now() const startedAt = Date.now()
try { try {
const res = await execShellCommand(cmd, cmdArgs) const res = await execShellCommand(cmd, cmdArgs)

56
src/utils/diffUtils.ts Normal file
View File

@ -0,0 +1,56 @@
import * as core from "@actions/core"
import * as path from "path"
// If needed alter diff file to be compatible with working directory
export function alterDiffPatch(patch: string): string {
const workingDirectory = core.getInput(`working-directory`)
if (workingDirectory) {
return alterPatchWithWorkingDirectory(patch, workingDirectory)
}
return patch
}
function alterPatchWithWorkingDirectory(patch: string, workingDirectory: string): string {
const workspace = process.env["GITHUB_WORKSPACE"] || ""
const wd = path.relative(workspace, workingDirectory)
// ignore diff sections not related to the working directory
let ignore = false
const lines = patch.split("\n")
const filteredLines = []
// starts with "--- a/xxx/" or "+++ a/xxx/" or "--- b/xxx/" or "+++ b/xxx/"
const cleanDiff = new RegExp(`^((?:\\+{3}|-{3}) [ab]\\/)${escapeRegExp(wd)}\\/(.*)`, "gm")
// contains " a/xxx/" or " b/xxx/"
const firstLine = new RegExp(`( [ab]\\/)${escapeRegExp(wd)}\\/(.*)`, "gm")
for (const line of lines) {
if (line.startsWith("diff --git")) {
ignore = !line.includes(` a/${wd}/`)
if (ignore) {
continue
}
filteredLines.push(line.replaceAll(firstLine, "$1$2"))
} else {
if (ignore) {
continue
}
filteredLines.push(line.replaceAll(cleanDiff, "$1$2"))
}
}
// Join the modified lines back into a diff string
return filteredLines.join("\n")
}
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
function escapeRegExp(exp: string): string {
return exp.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") // $& means the whole matched string
}

View File

@ -3,6 +3,8 @@ import * as httpm from "@actions/http-client"
import * as fs from "fs" import * as fs from "fs"
import path from "path" import path from "path"
import { InstallMode } from "./install"
// TODO: make a class // TODO: make a class
export type Version = { export type Version = {
major: number major: number
@ -17,6 +19,7 @@ const parseVersion = (s: string): Version => {
if (s == "latest" || s == "") { if (s == "latest" || s == "") {
return null return null
} }
const match = s.match(versionRe) const match = s.match(versionRe)
if (!match) { if (!match) {
throw new Error(`invalid version string '${s}', expected format v1.2 or v1.2.3`) throw new Error(`invalid version string '${s}', expected format v1.2 or v1.2.3`)
@ -61,6 +64,7 @@ const isLessVersion = (a: Version, b: Version): boolean => {
const getRequestedLintVersion = (): Version => { const getRequestedLintVersion = (): Version => {
let requestedLintVersion = core.getInput(`version`) let requestedLintVersion = core.getInput(`version`)
const workingDirectory = core.getInput(`working-directory`) const workingDirectory = core.getInput(`working-directory`)
let goMod = "go.mod" let goMod = "go.mod"
if (workingDirectory) { if (workingDirectory) {
goMod = path.join(workingDirectory, goMod) goMod = path.join(workingDirectory, goMod)
@ -79,6 +83,7 @@ const getRequestedLintVersion = (): Version => {
if (parsedRequestedLintVersion == null) { if (parsedRequestedLintVersion == null) {
return null return null
} }
if (isLessVersion(parsedRequestedLintVersion, minVersion)) { if (isLessVersion(parsedRequestedLintVersion, minVersion)) {
throw new Error( throw new Error(
`requested golangci-lint version '${requestedLintVersion}' isn't supported: we support only ${stringifyVersion( `requested golangci-lint version '${requestedLintVersion}' isn't supported: we support only ${stringifyVersion(
@ -86,6 +91,7 @@ const getRequestedLintVersion = (): Version => {
)} and later versions` )} and later versions`
) )
} }
return parsedRequestedLintVersion return parsedRequestedLintVersion
} }
@ -120,9 +126,16 @@ const getConfig = async (): Promise<Config> => {
} }
} }
export async function findLintVersion(): Promise<VersionConfig> { export async function findLintVersion(mode: InstallMode): Promise<VersionConfig> {
core.info(`Finding needed golangci-lint version...`) core.info(`Finding needed golangci-lint version...`)
if (mode == InstallMode.GoInstall) {
const v: string = core.getInput(`version`)
return { TargetVersion: v ? v : "latest", AssetURL: "github.com/golangci/golangci-lint" }
}
const reqLintVersion = getRequestedLintVersion() const reqLintVersion = getRequestedLintVersion()
// if the patched version is passed, just use it // if the patched version is passed, just use it
if (reqLintVersion?.major !== null && reqLintVersion?.minor != null && reqLintVersion?.patch !== null) { if (reqLintVersion?.major !== null && reqLintVersion?.minor != null && reqLintVersion?.patch !== null) {
return new Promise((resolve) => { return new Promise((resolve) => {
@ -133,6 +146,7 @@ export async function findLintVersion(): Promise<VersionConfig> {
}) })
}) })
} }
const startedAt = Date.now() const startedAt = Date.now()
const config = await getConfig() const config = await getConfig()
@ -155,5 +169,6 @@ export async function findLintVersion(): Promise<VersionConfig> {
Date.now() - startedAt Date.now() - startedAt
}ms` }ms`
) )
return versionConfig return versionConfig
} }

View File

@ -1,6 +1,6 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "target": "ES2021", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"outDir": "./lib", /* Redirect output structure to the directory. */ "outDir": "./lib", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */