Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gha: Enhance workflows #102

Merged
merged 7 commits into from Dec 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/stale.yml
@@ -1,4 +1,4 @@
name: "Close stale issues"
name: Stale

on:
schedule:
Expand All @@ -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
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Expand Up @@ -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:
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/update-major-tag.yml
@@ -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
3 changes: 0 additions & 3 deletions __tests__/get-os.test.ts
Expand Up @@ -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');
Expand Down
9 changes: 3 additions & 6 deletions __tests__/get-url.test.ts
Expand Up @@ -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");
// });
});
6 changes: 3 additions & 3 deletions lib/index.js
Expand Up @@ -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 {
Expand All @@ -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);
Expand All @@ -1926,7 +1926,7 @@ function run() {
else {
console.log(`Hugo version: ${hugoVersion}`);
yield installer_1.default(hugoVersion);
yield dump();
yield showVersion();
}
}
catch (error) {
Expand Down
1 change: 0 additions & 1 deletion src/get-os.ts
Expand Up @@ -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`);
}
Expand Down
7 changes: 3 additions & 4 deletions src/index.ts
Expand Up @@ -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');
};

Expand All @@ -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);
Expand All @@ -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);
Expand Down