diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 4213026..9397b4f 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -50,16 +50,20 @@ jobs: golint -set_exit_status=1 ./... release_check: runs-on: ubuntu-latest - outputs: - changes: ${{ steps.changes.outputs.changes}} steps: - name: Checkout repository uses: actions/checkout@v2 with: - fetch-depth: 2 - - name: Get changed files - id: changes + fetch-depth: 0 + - name: Check Diff + uses: technote-space/get-diff-action@v6 + with: + PATTERNS: | + +**/*.go + !**/*_test.go + FILES: | + go.mod + - name: Output Diff + if: env.GIT_DIFF run: | - 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)" - echo ${{ steps.changes.outputs.changes}} - \ No newline at end of file + echo ${{ env.GIT_DIFF }} diff --git a/.github/workflows/push_main.yaml b/.github/workflows/push_main.yaml index 7b78f71..6d20812 100644 --- a/.github/workflows/push_main.yaml +++ b/.github/workflows/push_main.yaml @@ -72,21 +72,27 @@ jobs: release_check: runs-on: ubuntu-latest needs: [test, lint] - outputs: - changes: ${{ steps.changes.outputs.changes}} steps: - name: Checkout repository uses: actions/checkout@v2 with: - fetch-depth: 2 - - name: Get changed files - id: changes + fetch-depth: 0 + - name: Check Diff + uses: technote-space/get-diff-action@v6 + with: + PATTERNS: | + +**/*.go + !**/*_test.go + FILES: | + go.mod + - name: Output Diff + if: env.GIT_DIFF run: | - echo "::set-output name=changes::$(git diff --name-only --diff-filter=ACMRT origin/main origin/${GITHUB_HEAD_REF} | grep 'go.mod\|.go$' | grep -v _test.go$ | xargs)" + echo ${{ env.GIT_DIFF }} release: runs-on: ubuntu-latest needs: [release_check] - if: ${{needs.release_check.outputs.changes}} + if: env.GIT_DIFF outputs: version: ${{ steps.release.outputs.version }} steps: diff --git a/options_test.go b/options_test.go index b38987a..8dc1c31 100644 --- a/options_test.go +++ b/options_test.go @@ -12,7 +12,6 @@ import ( var _ Option = OptionFunction(func(selector *Selector) error { return nil }) func Test_OptionFunction(t *testing.T) { - t.Run("nil", func(t *testing.T) { called := false option := OptionFunction(func(selector *Selector) error { @@ -23,7 +22,6 @@ func Test_OptionFunction(t *testing.T) { assert.Nil(t, err) assert.True(t, called) }) - t.Run("error", func(t *testing.T) { called := false option := OptionFunction(func(selector *Selector) error { @@ -34,13 +32,10 @@ func Test_OptionFunction(t *testing.T) { assert.EqualError(t, err, "fail") assert.True(t, called) }) - } func Test_ScriptEngine(t *testing.T) { - t.Run("first", func(t *testing.T) { - engine := &testScriptEngine{value: 1} option := ScriptEngine(engine) selector := &Selector{} @@ -48,10 +43,8 @@ func Test_ScriptEngine(t *testing.T) { err := option.Apply(selector) assert.Nil(t, err) assert.Equal(t, engine, selector.engine) - }) t.Run("second", func(t *testing.T) { - engine1 := &testScriptEngine{value: 1} engine2 := &testScriptEngine{value: 2} @@ -68,15 +61,11 @@ func Test_ScriptEngine(t *testing.T) { assert.Equal(t, engine1, selector.engine) assert.NotEqual(t, engine2, selector.engine) - }) - } func Test_QueryOptions(t *testing.T) { - t.Run("first", func(t *testing.T) { - input := &option.QueryOptions{AllowMapReferenceByIndex: true, AllowStringReferenceByIndex: true} option := QueryOptions(input) selector := &Selector{} @@ -84,10 +73,8 @@ func Test_QueryOptions(t *testing.T) { err := option.Apply(selector) assert.Nil(t, err) assert.Equal(t, input, selector.Options) - }) t.Run("second", func(t *testing.T) { - input1 := &option.QueryOptions{AllowMapReferenceByIndex: true, AllowStringReferenceByIndex: true} input2 := &option.QueryOptions{AllowMapReferenceByIndex: false, AllowStringReferenceByIndex: false} @@ -104,7 +91,5 @@ func Test_QueryOptions(t *testing.T) { assert.Equal(t, input1, selector.Options) assert.NotEqual(t, input2, selector.Options) - }) - }