From edf6abce99aecc78241732a7cd54f449cd7d1ebf Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Fri, 4 Dec 2020 11:02:12 +0530 Subject: [PATCH] ci: add github workflows for static checks adding a github workflow to run static checks inside a container. Signed-off-by: Madhu Rajanna --- .github/workflows/commitlint.yaml | 15 +++++++ .github/workflows/go-test.yaml | 15 +++++++ .github/workflows/golanci-lint.yaml | 15 +++++++ .github/workflows/gosec.yaml | 15 +++++++ .github/workflows/lint-extras.yaml | 15 +++++++ .github/workflows/mod-check.yaml | 15 +++++++ .travis.yml | 69 +---------------------------- 7 files changed, 92 insertions(+), 67 deletions(-) create mode 100644 .github/workflows/commitlint.yaml create mode 100644 .github/workflows/go-test.yaml create mode 100644 .github/workflows/golanci-lint.yaml create mode 100644 .github/workflows/gosec.yaml create mode 100644 .github/workflows/lint-extras.yaml create mode 100644 .github/workflows/mod-check.yaml diff --git a/.github/workflows/commitlint.yaml b/.github/workflows/commitlint.yaml new file mode 100644 index 000000000..d04a69d29 --- /dev/null +++ b/.github/workflows/commitlint.yaml @@ -0,0 +1,15 @@ +--- +name: commitlint +# yamllint disable-line rule:truthy +on: + pull_request: + branches: + - '*' +jobs: + commitlint: + name: commitlint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: commitlint + run: CONTAINER_CMD=docker make containerized-test TARGET=commitlint diff --git a/.github/workflows/go-test.yaml b/.github/workflows/go-test.yaml new file mode 100644 index 000000000..2f25304b7 --- /dev/null +++ b/.github/workflows/go-test.yaml @@ -0,0 +1,15 @@ +--- +name: go-test +# yamllint disable-line rule:truthy +on: + pull_request: + branches: + - '*' +jobs: + go-test: + name: go-test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: go-test + run: CONTAINER_CMD=docker make containerized-test TARGET=go-test diff --git a/.github/workflows/golanci-lint.yaml b/.github/workflows/golanci-lint.yaml new file mode 100644 index 000000000..7c6472e00 --- /dev/null +++ b/.github/workflows/golanci-lint.yaml @@ -0,0 +1,15 @@ +--- +name: golangci-lint +# yamllint disable-line rule:truthy +on: + pull_request: + branches: + - '*' +jobs: + golangci-lint: + name: golangci-lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: golangci-lint + run: CONTAINER_CMD=docker make containerized-test TARGET=go-lint diff --git a/.github/workflows/gosec.yaml b/.github/workflows/gosec.yaml new file mode 100644 index 000000000..ba6816a0d --- /dev/null +++ b/.github/workflows/gosec.yaml @@ -0,0 +1,15 @@ +--- +name: gosec +# yamllint disable-line rule:truthy +on: + pull_request: + branches: + - '*' +jobs: + gosec: + name: gosec + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: gosec + run: CONTAINER_CMD=docker make containerized-test TARGET=gosec diff --git a/.github/workflows/lint-extras.yaml b/.github/workflows/lint-extras.yaml new file mode 100644 index 000000000..a5fe7b870 --- /dev/null +++ b/.github/workflows/lint-extras.yaml @@ -0,0 +1,15 @@ +--- +name: lint-extras +# yamllint disable-line rule:truthy +on: + pull_request: + branches: + - '*' +jobs: + lint-extras: + name: lint-extras + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: lint-extras + run: CONTAINER_CMD=docker make containerized-test TARGET=lint-extras diff --git a/.github/workflows/mod-check.yaml b/.github/workflows/mod-check.yaml new file mode 100644 index 000000000..247f7ba3c --- /dev/null +++ b/.github/workflows/mod-check.yaml @@ -0,0 +1,15 @@ +--- +name: mod-check +# yamllint disable-line rule:truthy +on: + pull_request: + branches: + - '*' +jobs: + mod-check: + name: mod-check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: mod-check + run: CONTAINER_CMD=docker make containerized-test TARGET=mod-check diff --git a/.travis.yml b/.travis.yml index 4c985f779..8669d70c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,82 +16,17 @@ language: go branches: only: - master - -env: - global: - - GO111MODULE=on - - KUBECONFIG=$HOME/.kube/config - # set CEPH_CSI_RUN_ALL_TESTS to non-empty to run all tests - - CEPH_CSI_RUN_ALL_TESTS=true - -before_install: - - export GOLANG_VERSION=$(source build.env ; echo ${GOLANG_VERSION}) - - gimme ${GOLANG_VERSION} - - source ~/.gimme/envs/go${GOLANG_VERSION}.env - - mkdir -p $GOPATH/bin - # csi release to use for upgrade testing - - export UPGRADE_VERSION=$(source build.env ; echo ${UPGRADE_VERSION}) - -before_script: - - export CV=$(source build.env ; echo ${CEPH_VERSION}) - - test -z "${CV}" || export GO_TAGS="-tags=${CV}" - - curl https://download.ceph.com/keys/release.asc | sudo apt-key add - - - sudo apt-add-repository - "deb https://download.ceph.com/debian-${CV} $(lsb_release -sc) main" - # yamllint enable rule:line-length - - sudo apt-get -qq update - # only the arm64 fallback repo is unsigned and needs --allow-unauthenticated - - sudo apt-get -y --allow-unauthenticated install librados-dev librbd-dev - - sudo apt-get -y install conntrack - -# Two stages for testing, each stage runs its jobs in parallel, but stages are -# run after each other, unless the last stage fails. # Only run the deploy stage on push (not pull_request) events. stages: - - build testing - - upgrade testing - name: deploy if: type = push jobs: include: - - stage: build testing - name: static-check-make + - stage: deploy + name: push artifacts to repositories install: - - gem install mdl - - pip install --user --upgrade pip - - pip install --user yamllint - # install golangci-lint - - export GOLANGCI_VERSION=$(source build.env ; echo ${GOLANGCI_VERSION}) - - curl -sf - "https://install.goreleaser.com/github.com/golangci/golangci-lint.sh" - | bash -s -- -b $GOPATH/bin "${GOLANGCI_VERSION}" - # install gosec - - export GOSEC_VERSION=$(source build.env ; echo ${GOSEC_VERSION}) - - curl -sfL - "https://raw.githubusercontent.com/securego/gosec/master/install.sh" - | sh -s -- -b $GOPATH/bin "${GOSEC_VERSION}" - # install helm for helm lint - export HELM_VERSION=$(source build.env ; echo ${HELM_VERSION}) - curl -L https://git.io/get_helm.sh | bash -s -- -v "${HELM_VERSION}" - # yamllint disable rule:line-length - - mkdir -p /opt/commitlint && pushd /opt/commitlint - && npm init -y && npm install --save-dev @commitlint/travis-cli && popd - - export PATH=/opt/commitlint/node_modules/.bin:$PATH - # install pylint and prettytable. - # target python script requires python3 dependencies. - - sudo apt install python3-pip python3-prettytable python3-setuptools python3-wheel -y - - pip3 install pylint - # yamllint enable rule:line-length - script: - - commitlint-travis - - make go-lint - - make lint-extras - - make gosec - - make go-test TEST_COVERAGE=stdout GO_COVER_DIR=_output/ - - make mod-check - - - stage: deploy - name: push artifacts to repositories script: ./deploy.sh