From 7a87a784bf4d6192734a917183f39e06c043189d Mon Sep 17 00:00:00 2001 From: Marko Date: Tue, 28 Apr 2020 16:07:11 +0200 Subject: [PATCH] ci: only run when applicable (#4752) - only run tests when .go, .mod, .sum files have been touched - only run proto checks when .proto files have been touched Signed-off-by: Marko Baricevic marbar3778@yahoo.com --- .github/workflows/proto.yml | 9 ++++++++- .github/workflows/tests.yml | 36 ++++++++++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/.github/workflows/proto.yml b/.github/workflows/proto.yml index ddc9ee4c4..3add52404 100644 --- a/.github/workflows/proto.yml +++ b/.github/workflows/proto.yml @@ -5,8 +5,15 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@master - - uses: docker-practice/actions-setup-docker@master + - uses: technote-space/get-diff-action@v1 + id: git_diff + with: + SUFFIX_FILTER: .proto + SET_ENV_NAME_INSERTIONS: 1 + SET_ENV_NAME_LINES: 1 - name: lint run: make proto-lint + if: "env.GIT_DIFF != ''" - name: check-breakage run: make proto-check-breaking-ci + if: "env.GIT_DIFF != ''" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 75ca8b4a0..54417c490 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,6 +7,23 @@ on: - release/** jobs: + Diff: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: technote-space/get-diff-action@v1 + id: git_diff + with: + SUFFIX_FILTER: | + .go + .mod + .sum + SET_ENV_NAME_INSERTIONS: 1 + SET_ENV_NAME_LINES: 1 + - name: test + run: exit 1 + if: "env.GIT_DIFF == ''" + cleanup-runs: runs-on: ubuntu-latest steps: @@ -14,6 +31,7 @@ jobs: env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'" + build: name: Build runs-on: ubuntu-latest @@ -33,7 +51,7 @@ jobs: test_abci_apps: runs-on: ubuntu-latest - needs: Build + needs: [Build, Diff] steps: - uses: actions/setup-go@v2-beta - name: Set GOBIN @@ -50,7 +68,7 @@ jobs: test_abci_cli: runs-on: ubuntu-latest - needs: Build + needs: [Build, Diff] steps: - uses: actions/setup-go@v2-beta - name: Set GOBIN @@ -68,15 +86,25 @@ jobs: runs-on: ubuntu-latest needs: Build steps: - - uses: actions/setup-go@v2-beta + - uses: actions/checkout@v2 + - uses: technote-space/get-diff-action@v1 + id: git_diff + with: + SUFFIX_FILTER: | + .go + .mod + .sum + SET_ENV_NAME_INSERTIONS: 1 + SET_ENV_NAME_LINES: 1 - name: Set GOBIN run: | echo "::add-path::$(go env GOPATH)/bin" - - uses: actions/checkout@v2 - uses: actions/cache@v1 with: path: ~/go/bin key: ${{ runner.os }}-go-tm-binary + if: "env.GIT_DIFF != ''" - name: test_apps run: test/app/test.sh shell: bash + if: "env.GIT_DIFF != ''"