WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 739a95f

Browse files
authored
gha: Enhance workflows (#102)
* gha: Add Pull Request to stale target * gha: Add ncc check step (Close #98 ) * src: Rename showVersion() * test: Add not to be cases * Remove old comment * gha: Add update major tag workflow (Close #97 )
1 parent bc6f48c commit 739a95f

File tree

8 files changed

+40
-18
lines changed

8 files changed

+40
-18
lines changed

.github/workflows/stale.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Close stale issues"
1+
name: Stale
22

33
on:
44
schedule:
@@ -12,5 +12,6 @@ jobs:
1212
with:
1313
repo-token: ${{ secrets.GITHUB_TOKEN }}
1414
stale-issue-message: 'This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
15+
stale-pr-message: 'This pull request is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
1516
days-before-stale: 21
1617
days-before-close: 7

.github/workflows/test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ jobs:
4545

4646
- run: npm test
4747

48+
- name: Check ncc
49+
run: |
50+
npm run build
51+
test -z "$(git status --short)"
52+
4853
- name: Upload test coverage
4954
uses: actions/upload-artifact@v1
5055
with:
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Update major tag
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
update:
9+
runs-on: ubuntu-18.04
10+
steps:
11+
12+
- uses: actions/checkout@v1
13+
14+
- name: Update major tag
15+
if: github.event.release.prerelease == false
16+
run: |
17+
git config user.name "${GITHUB_ACTOR}"
18+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
19+
git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
20+
export TAG_NAME="${GITHUB_REF##refs/tags/}"
21+
export TAG_MAJOR="${TAG_NAME%%.*}"
22+
git tag "${TAG_MAJOR}" || git tag -d "${TAG_MAJOR}" ; git push origin ":refs/tags/${TAG_MAJOR}"
23+
git tag "${TAG_MAJOR}" || true
24+
git push --tags origin

__tests__/get-os.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ describe('getOS', () => {
88
});
99

1010
test('test exception', () => {
11-
// expect(() => {
12-
// getOS("win32");
13-
// }).toThrowError("Windows is not supported");
1411
expect(() => {
1512
getOS('centos');
1613
}).toThrowError('centos is not supported');

__tests__/get-url.test.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@ describe('getURL()', () => {
99
const urlMacOS = `${baseURL}/hugo_0.58.2_macOS-64bit.tar.gz`;
1010
const urlWindows = `${baseURL}/hugo_0.58.2_Windows-64bit.zip`;
1111
expect(getURL('Linux', 'false', '0.58.2')).toBe(urlLinux);
12+
expect(getURL('Linux', 'true', '0.58.2')).not.toBe(urlLinux);
13+
expect(getURL('MyOS', 'false', '0.58.2')).not.toBe(urlLinux);
14+
expect(getURL('Linux', 'false', '0.58.1')).not.toBe(urlLinux);
1215
expect(getURL('Linux', 'true', '0.58.2')).toBe(urlLinuxExtended);
1316
expect(getURL('macOS', 'false', '0.58.2')).toBe(urlMacOS);
1417
expect(getURL('Windows', 'false', '0.58.2')).toBe(urlWindows);
1518
});
16-
17-
// test("test exception", () => {
18-
// expect(() => {
19-
// getURL("Linux", "hoge", "0.58.2");
20-
// }).toThrowError("Invalid input (extended): hoge");
21-
// });
2219
});

lib/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,7 +1907,7 @@ const get_latest_version_1 = __importDefault(__webpack_require__(307));
19071907
const installer_1 = __importDefault(__webpack_require__(923));
19081908
function run() {
19091909
return __awaiter(this, void 0, void 0, function* () {
1910-
const dump = () => __awaiter(this, void 0, void 0, function* () {
1910+
const showVersion = () => __awaiter(this, void 0, void 0, function* () {
19111911
yield exec.exec('hugo version');
19121912
});
19131913
try {
@@ -1917,7 +1917,7 @@ function run() {
19171917
return __awaiter(this, void 0, void 0, function* () {
19181918
console.log(`Hugo version: ${latestVersion} (${hugoVersion})`);
19191919
yield installer_1.default(latestVersion);
1920-
yield dump();
1920+
yield showVersion();
19211921
});
19221922
}, function (error) {
19231923
core.setFailed(error);
@@ -1926,7 +1926,7 @@ function run() {
19261926
else {
19271927
console.log(`Hugo version: ${hugoVersion}`);
19281928
yield installer_1.default(hugoVersion);
1929-
yield dump();
1929+
yield showVersion();
19301930
}
19311931
}
19321932
catch (error) {

src/get-os.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export default function getOS(platform: string) {
55
return 'macOS';
66
} else if (platform === 'win32') {
77
return 'Windows';
8-
// throw new Error("Windows is not supported");
98
} else {
109
throw new Error(`${platform} is not supported`);
1110
}

src/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import installer from './installer';
55

66
// most @actions toolkit packages have async methods
77
async function run() {
8-
const dump = async () => {
9-
// Show version
8+
const showVersion = async () => {
109
await exec.exec('hugo version');
1110
};
1211

@@ -18,7 +17,7 @@ async function run() {
1817
async function(latestVersion): Promise<void> {
1918
console.log(`Hugo version: ${latestVersion} (${hugoVersion})`);
2019
await installer(latestVersion);
21-
await dump();
20+
await showVersion();
2221
},
2322
function(error) {
2423
core.setFailed(error);
@@ -27,7 +26,7 @@ async function run() {
2726
} else {
2827
console.log(`Hugo version: ${hugoVersion}`);
2928
await installer(hugoVersion);
30-
await dump();
29+
await showVersion();
3130
}
3231
} catch (error) {
3332
core.setFailed(error.message);

0 commit comments

Comments
 (0)