Skip to content

Commit bb450e4

Browse files
authored
Add tests
1 parent 79b6548 commit bb450e4

29 files changed

Lines changed: 5491 additions & 452 deletions

File tree

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
name: test
1+
name: ci
22

33
on:
44
pull_request:
55
branches: master
66
push:
77
branches: master
8-
tags:
98

109
jobs:
11-
test:
10+
ci:
1211
runs-on: ${{ matrix.os }}
1312
strategy:
13+
fail-fast: false
1414
matrix:
1515
os:
1616
- ubuntu-latest

.github/workflows/test.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: test
2+
3+
on:
4+
pull_request:
5+
branches: master
6+
push:
7+
branches: master
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
-
14+
# https://github.com/actions/checkout
15+
name: Checkout
16+
uses: actions/checkout@v1
17+
-
18+
name: Install
19+
run: npm ci
20+
-
21+
name: Build
22+
run: npm run build
23+
-
24+
name: Test
25+
run: npm run test
26+
-
27+
name: Check for uncommitted changes
28+
# Ensure no changes, but ignore node_modules dir since dev/fresh ci deps installed.
29+
run: |
30+
git diff --exit-code --stat -- . ':!node_modules' \
31+
|| (echo "##[error] found changed files after build. please 'npm run build && npm run format'" \
32+
"and check in all changes" \
33+
&& exit 1)

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/.dev
2+
/dist
23

34
# Jetbrains
45
/.idea

__tests__/installer.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import fs = require('fs');
2+
import * as installer from '../src/installer';
3+
4+
describe('installer', () => {
5+
it('acquires v0.117.0 version of GoReleaser', async () => {
6+
const goreleaser = await installer.getGoReleaser('v0.117.0');
7+
expect(fs.existsSync(goreleaser)).toBe(true);
8+
}, 100000);
9+
10+
it('acquires latest version of GoReleaser', async () => {
11+
const goreleaser = await installer.getGoReleaser('latest');
12+
expect(fs.existsSync(goreleaser)).toBe(true);
13+
}, 100000);
14+
});

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/crazy-max/ghaction-goreleaser
2+
3+
go 1.12

jest.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
clearMocks: true,
3+
moduleFileExtensions: ['js', 'ts'],
4+
testEnvironment: 'node',
5+
testMatch: ['**/*.test.ts'],
6+
testRunner: 'jest-circus/runner',
7+
transform: {
8+
'^.+\\.ts$': 'ts-jest'
9+
},
10+
verbose: true
11+
}

lib/installer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function getGoReleaser(version) {
4545
else {
4646
extPath = yield tc.extractTar(`${tmpdir}/${fileName}`);
4747
}
48-
return path.join(extPath, 'goreleaser');
48+
return path.join(extPath, osPlat == 'win32' ? 'goreleaser.exe' : 'goreleaser');
4949
});
5050
}
5151
exports.getGoReleaser = getGoReleaser;

lib/main.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
1919
const installer = __importStar(require("./installer"));
2020
const core = __importStar(require("@actions/core"));
2121
const exec = __importStar(require("@actions/exec"));
22-
function run() {
22+
function run(silent) {
2323
return __awaiter(this, void 0, void 0, function* () {
2424
try {
2525
const version = core.getInput('version') || 'latest';
2626
const args = core.getInput('args');
2727
const goreleaser = yield installer.getGoReleaser(version);
2828
let snapshot = '';
29-
if (!process.env.GITHUB_REF.startsWith('refs/tags/')) {
29+
if (!process.env.GITHUB_REF ||
30+
!process.env.GITHUB_REF.startsWith('refs/tags/')) {
3031
console.log(`⚠️ No tag found. Snapshot forced`);
3132
if (!args.includes('--snapshot')) {
3233
snapshot = ' --snapshot';
@@ -36,11 +37,14 @@ function run() {
3637
console.log(`✅ ${process.env.GITHUB_REF.split('/')[2]} tag found`);
3738
}
3839
console.log('🏃 Running GoReleaser...');
39-
yield exec.exec(`${goreleaser} ${args}${snapshot}`);
40+
yield exec.exec(`${goreleaser} ${args}${snapshot}`, undefined, {
41+
silent: silent
42+
});
4043
}
4144
catch (error) {
4245
core.setFailed(error.message);
4346
}
4447
});
4548
}
49+
exports.run = run;
4650
run();

node_modules/core-util-is/package.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/decode-uri-component/package.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)