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 )
This commit is contained in:
Shohei Ueda 2019-12-08 15:45:59 +09:00 committed by GitHub
parent bc6f48c683
commit 739a95f1e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 40 additions and 18 deletions

View File

@ -1,4 +1,4 @@
name: "Close stale issues"
name: Stale
on:
schedule:
@ -12,5 +12,6 @@ jobs:
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
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.'
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.'
days-before-stale: 21
days-before-close: 7

View File

@ -45,6 +45,11 @@ jobs:
- run: npm test
- name: Check ncc
run: |
npm run build
test -z "$(git status --short)"
- name: Upload test coverage
uses: actions/upload-artifact@v1
with:

24
.github/workflows/update-major-tag.yml vendored Normal file
View File

@ -0,0 +1,24 @@
name: Update major tag
on:
release:
types: [published]
jobs:
update:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- name: Update major tag
if: github.event.release.prerelease == false
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
export TAG_NAME="${GITHUB_REF##refs/tags/}"
export TAG_MAJOR="${TAG_NAME%%.*}"
git tag "${TAG_MAJOR}" || git tag -d "${TAG_MAJOR}" ; git push origin ":refs/tags/${TAG_MAJOR}"
git tag "${TAG_MAJOR}" || true
git push --tags origin

View File

@ -8,9 +8,6 @@ describe('getOS', () => {
});
test('test exception', () => {
// expect(() => {
// getOS("win32");
// }).toThrowError("Windows is not supported");
expect(() => {
getOS('centos');
}).toThrowError('centos is not supported');

View File

@ -9,14 +9,11 @@ describe('getURL()', () => {
const urlMacOS = `${baseURL}/hugo_0.58.2_macOS-64bit.tar.gz`;
const urlWindows = `${baseURL}/hugo_0.58.2_Windows-64bit.zip`;
expect(getURL('Linux', 'false', '0.58.2')).toBe(urlLinux);
expect(getURL('Linux', 'true', '0.58.2')).not.toBe(urlLinux);
expect(getURL('MyOS', 'false', '0.58.2')).not.toBe(urlLinux);
expect(getURL('Linux', 'false', '0.58.1')).not.toBe(urlLinux);
expect(getURL('Linux', 'true', '0.58.2')).toBe(urlLinuxExtended);
expect(getURL('macOS', 'false', '0.58.2')).toBe(urlMacOS);
expect(getURL('Windows', 'false', '0.58.2')).toBe(urlWindows);
});
// test("test exception", () => {
// expect(() => {
// getURL("Linux", "hoge", "0.58.2");
// }).toThrowError("Invalid input (extended): hoge");
// });
});

View File

@ -1907,7 +1907,7 @@ const get_latest_version_1 = __importDefault(__webpack_require__(307));
const installer_1 = __importDefault(__webpack_require__(923));
function run() {
return __awaiter(this, void 0, void 0, function* () {
const dump = () => __awaiter(this, void 0, void 0, function* () {
const showVersion = () => __awaiter(this, void 0, void 0, function* () {
yield exec.exec('hugo version');
});
try {
@ -1917,7 +1917,7 @@ function run() {
return __awaiter(this, void 0, void 0, function* () {
console.log(`Hugo version: ${latestVersion} (${hugoVersion})`);
yield installer_1.default(latestVersion);
yield dump();
yield showVersion();
});
}, function (error) {
core.setFailed(error);
@ -1926,7 +1926,7 @@ function run() {
else {
console.log(`Hugo version: ${hugoVersion}`);
yield installer_1.default(hugoVersion);
yield dump();
yield showVersion();
}
}
catch (error) {

View File

@ -5,7 +5,6 @@ export default function getOS(platform: string) {
return 'macOS';
} else if (platform === 'win32') {
return 'Windows';
// throw new Error("Windows is not supported");
} else {
throw new Error(`${platform} is not supported`);
}

View File

@ -5,8 +5,7 @@ import installer from './installer';
// most @actions toolkit packages have async methods
async function run() {
const dump = async () => {
// Show version
const showVersion = async () => {
await exec.exec('hugo version');
};
@ -18,7 +17,7 @@ async function run() {
async function(latestVersion): Promise<void> {
console.log(`Hugo version: ${latestVersion} (${hugoVersion})`);
await installer(latestVersion);
await dump();
await showVersion();
},
function(error) {
core.setFailed(error);
@ -27,7 +26,7 @@ async function run() {
} else {
console.log(`Hugo version: ${hugoVersion}`);
await installer(hugoVersion);
await dump();
await showVersion();
}
} catch (error) {
core.setFailed(error.message);