Skip to content

Commit c1ea01a

Browse files
chore: fix tests broke in refactor (#17)
* chore: fix tests broke in refactor union tests were skipped during refactor * chore: add logic to do dry run on pr when there are code changes that should cause new release a dry-run is done to output expected version
1 parent 96598ba commit c1ea01a

File tree

4 files changed

+49
-7
lines changed

4 files changed

+49
-7
lines changed

.github/workflows/pull_request.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,31 @@ jobs:
4848
- name: Run Lint
4949
run: |
5050
golint -set_exit_status=1 ./...
51+
release_check:
52+
runs-on: ubuntu-latest
53+
outputs:
54+
changes: ${{ steps.changes.outputs.changes}}
55+
steps:
56+
- name: Checkout repository
57+
uses: actions/checkout@v2
58+
with:
59+
fetch-depth: 2
60+
- name: Get changed files
61+
id: changes
62+
run: |
63+
echo "::set-output name=changes::$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep 'go.mod\|.go$' | grep -v _test.go$ | xargs)"
64+
dry_run:
65+
runs-on: ubuntu-latest
66+
needs: release_check
67+
if: ${{needs.release_check.outputs.changes}}
68+
outputs:
69+
version: ${{ steps.release.outputs.version }}
70+
steps:
71+
- uses: actions/checkout@master
72+
- uses: go-semantic-release/action@v1
73+
id: release
74+
with:
75+
github-token: ${{ secrets.GITHUB_TOKEN }}
76+
allow-initial-development-versions: true
77+
force-bump-patch-version: true
78+
dry: true

.github/workflows/push_main.yaml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,23 @@ jobs:
6969
files: ./coverage.txt
7070
fail_ci_if_error: true
7171
verbose: true
72+
release_check:
73+
runs-on: ubuntu-latest
74+
outputs:
75+
changes: ${{ steps.changes.outputs.changes}}
76+
steps:
77+
- name: Checkout repository
78+
uses: actions/checkout@v2
79+
with:
80+
fetch-depth: 2
81+
- name: Get changed files
82+
id: changes
83+
run: |
84+
echo "::set-output name=changes::$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep 'go.mod\|.go$' | grep -v _test.go$ | xargs)"
7285
release:
7386
runs-on: ubuntu-latest
74-
needs: [test, lint]
87+
needs: [release_check]
88+
if: ${{needs.release_check.outputs.changes}}
7589
outputs:
7690
version: ${{ steps.release.outputs.version }}
7791
steps:
@@ -83,8 +97,8 @@ jobs:
8397
allow-initial-development-versions: true
8498
force-bump-patch-version: true
8599
build:
86-
if: needs.release.outputs.version != ''
87100
needs: [release]
101+
if: needs.release.outputs.version != ''
88102
runs-on: ubuntu-latest
89103
strategy:
90104
matrix:

token/root_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func Test_RootToken_Type(t *testing.T) {
2121
assert.Equal(t, "root", (&rootToken{}).Type())
2222
}
2323

24-
var tests = []*tokenTest{
24+
var rootTests = []*tokenTest{
2525
{
2626
token: &rootToken{},
2727
input: input{
@@ -52,9 +52,9 @@ var tests = []*tokenTest{
5252
}
5353

5454
func Test_RootToken_Apply(t *testing.T) {
55-
batchTokenTests(t, tests)
55+
batchTokenTests(t, rootTests)
5656
}
5757

5858
func Benchmark_RootToken_Apply(b *testing.B) {
59-
batchTokenBenchmarks(b, tests)
59+
batchTokenBenchmarks(b, rootTests)
6060
}

token/union_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,11 +429,11 @@ var unionTests = []*tokenTest{
429429
}
430430

431431
func Test_UnionToken_Apply(t *testing.T) {
432-
batchTokenTests(t, tests)
432+
batchTokenTests(t, unionTests)
433433
}
434434

435435
func Benchmark_UnionToken_Apply(b *testing.B) {
436-
batchTokenBenchmarks(b, tests)
436+
batchTokenBenchmarks(b, unionTests)
437437
}
438438

439439
func Test_UnionToken_getUnionByIndex(t *testing.T) {

0 commit comments

Comments
 (0)