From 16c5b2d8506dc5f39501017bff2d6fc1a9e2bca3 Mon Sep 17 00:00:00 2001 From: Ahmed Hassanin Date: Tue, 19 Nov 2024 18:02:19 +0100 Subject: [PATCH] Enhance Go CI --- .github/workflows/go.yml | 35 +++++++++++++++-------------------- .golangci.yml | 11 +++++++++++ 2 files changed, 26 insertions(+), 20 deletions(-) create mode 100644 .golangci.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index f8245d0b..5c6d33f7 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -9,12 +9,15 @@ on: pull_request: paths: - 'src/openstack_cpi_golang/**' + push: + paths: + - 'src/openstack_cpi_golang/**' jobs: go: strategy: matrix: - os: [macos-latest, windows-2019, ubuntu-latest] + os: [macos-latest, ubuntu-latest] name: Run tests and Lint on ${{ matrix.os }} runs-on: ${{ matrix.os }} @@ -28,22 +31,14 @@ jobs: go-version-file: src/openstack_cpi_golang/go.mod - name: Install golangci-lint - run: | - go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest - - - name: Run golangci-lint and tests on Windows - if: ${{ matrix.os == 'windows-2019' }} - run: | - cd src/openstack_cpi_golang - golangci-lint run - go test ./cpi/... - go test ./integration/... - - - name: Run golangci-lint and tests on non-Windows - if: ${{ matrix.os != 'windows-2019' }} - run: | - cd src/openstack_cpi_golang - golangci-lint run --enable goimports - go test ./cpi/... - go test ./integration/... - shell: bash \ No newline at end of file + uses: golangci/golangci-lint-action@v6 + with: + working-directory: src/openstack_cpi_golang + + - name: Run unit tests + run: scripts/run-unit-tests + working-directory: src/openstack_cpi_golang + + - name: Run integration tests + run: scripts/run-integration-tests + working-directory: src/openstack_cpi_golang \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..7ea90d73 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,11 @@ +# https://golangci-lint.run/usage/configuration/ +run: + timeout: 3m # 1m default times out on github-action runners + +linters: + enable: + - goimports + +output: + # Sort results by: filepath, line and column. + sort-results: true \ No newline at end of file