From 1b8b850cc0879c1e650960deabd7e90344a2f5a2 Mon Sep 17 00:00:00 2001 From: Matt Moore Date: Mon, 31 Aug 2020 10:19:16 -0700 Subject: [PATCH] [master] Update GitHub Actions (#3972) Copied from `https://github.com/knative/.github/tree/master/workflow-templates`. /assign grantr matzew n3wscott /cc grantr matzew n3wscott --- .github/workflows/knative-go-build.yaml | 49 ++++++++++++++++ .github/workflows/knative-go-test.yaml | 46 +++++++++++++++ .github/workflows/knative-stale.yaml | 31 +++++++++++ .github/workflows/knative-style.yaml | 57 +++++++++++++++++++ .github/workflows/knative-verify.yaml | 74 +++++++++++++++++++++++++ 5 files changed, 257 insertions(+) create mode 100644 .github/workflows/knative-go-build.yaml create mode 100644 .github/workflows/knative-go-test.yaml create mode 100644 .github/workflows/knative-stale.yaml create mode 100644 .github/workflows/knative-style.yaml create mode 100644 .github/workflows/knative-verify.yaml diff --git a/.github/workflows/knative-go-build.yaml b/.github/workflows/knative-go-build.yaml new file mode 100644 index 00000000000..81b9b0084e9 --- /dev/null +++ b/.github/workflows/knative-go-build.yaml @@ -0,0 +1,49 @@ +# Copyright 2020 The Knative Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Build + +on: + push: + branches: [ 'master', 'release-*' ] + pull_request: + branches: [ 'master', 'release-*' ] + +jobs: + + build: + name: Build + strategy: + matrix: + go-version: [1.15.x] + platform: [ubuntu-latest] + + runs-on: ${{ matrix.platform }} + + steps: + + - name: Set up Go ${{ matrix.go-version }} + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + id: go + + - name: Check out code + uses: actions/checkout@v2 + + - name: Vet + run: go vet ./... + + - name: Build + run: go build -v ./... diff --git a/.github/workflows/knative-go-test.yaml b/.github/workflows/knative-go-test.yaml new file mode 100644 index 00000000000..53985abd7c8 --- /dev/null +++ b/.github/workflows/knative-go-test.yaml @@ -0,0 +1,46 @@ +# Copyright 2020 The Knative Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Test + +on: + push: + branches: [ 'master', 'release-*' ] + pull_request: + branches: [ 'master', 'release-*' ] + +jobs: + + test: + name: Test + strategy: + matrix: + go-version: [1.15.x] + platform: [ubuntu-latest] + + runs-on: ${{ matrix.platform }} + + steps: + + - name: Set up Go ${{ matrix.go-version }} + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + id: go + + - name: Check out code + uses: actions/checkout@v2 + + - name: Test + run: go test -race ./... diff --git a/.github/workflows/knative-stale.yaml b/.github/workflows/knative-stale.yaml new file mode 100644 index 00000000000..3983efbe8e3 --- /dev/null +++ b/.github/workflows/knative-stale.yaml @@ -0,0 +1,31 @@ +name: 'Close stale' +on: + schedule: + - cron: '* * * * *' + +jobs: + stale: + runs-on: 'ubuntu-latest' + steps: + - uses: 'actions/stale@v3' + with: + repo-token: '${{ secrets.GITHUB_TOKEN }}' # No need to setup + + stale-issue-message: |- + This issue is stale because it has been open for 90 days with no + activity. It will automatically close after 30 more days of + inactivity. Reopen the issue with `/reopen`. Mark the issue as + fresh by adding the comment `/remove-lifecycle stale`. + stale-issue-label: 'lifecycle/stale' + exempt-issue-labels: 'lifecycle/frozen' + + stale-pr-message: |- + This Pull Request is stale because it has been open for 90 days with + no activity. It will automatically close after 30 more days of + inactivity. Reopen with `/reopen`. Mark as fresh by adding the + comment `/remove-lifecycle stale`. + stale-pr-label: 'lifecycle/stale' + exempt-pr-labels: 'lifecycle/frozen' + + days-before-stale: 90 + days-before-close: 30 diff --git a/.github/workflows/knative-style.yaml b/.github/workflows/knative-style.yaml new file mode 100644 index 00000000000..e6dca76c3db --- /dev/null +++ b/.github/workflows/knative-style.yaml @@ -0,0 +1,57 @@ +# Copyright 2020 The Knative Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Code Style + +on: + push: + branches: [ 'master', 'release-*' ] + pull_request: + branches: [ 'master', 'release-*' ] + +jobs: + + lint: + name: Lint + runs-on: ubuntu-latest + + steps: + + - name: Set up Go 1.15.x + uses: actions/setup-go@v2 + with: + go-version: 1.15.x + id: go + + - name: Check out code + uses: actions/checkout@v2 + + # TODO: add prettier step + # TODO: add goimports step + + - name: Go Format + shell: bash + run: | + gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print) + + - name: Verify + shell: bash + run: | + if [[ $(git diff-index --name-only HEAD --) ]]; then + echo "Found diffs in:" + git diff-index --name-only HEAD -- + echo "${{ github.repository }} is out of style. Please run go fmt." + exit 1 + fi + echo "${{ github.repository }} is formatted correctly." diff --git a/.github/workflows/knative-verify.yaml b/.github/workflows/knative-verify.yaml new file mode 100644 index 00000000000..6128969f3c8 --- /dev/null +++ b/.github/workflows/knative-verify.yaml @@ -0,0 +1,74 @@ +# Copyright 2020 The Knative Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Verify + +on: + push: + branches: [ 'master', 'release-*' ] + pull_request: + branches: [ 'master', 'release-*' ] + +jobs: + + verify: + name: Verify Deps and Codegen + strategy: + matrix: + go-version: [1.15.x] + platform: [ubuntu-latest] + + runs-on: ${{ matrix.platform }} + + env: + GOPATH: ${{ github.workspace }} + + steps: + + - name: Set up Go ${{ matrix.go-version }} + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + id: go + + - name: Install Dependencies + run: | + go get github.com/google/ko/cmd/ko + go get github.com/google/go-licenses + + - name: Check out code onto GOPATH + uses: actions/checkout@v2 + with: + path: ./src/knative.dev/${{ github.event.repository.name }} + + - name: Update Codegen + shell: bash + run: | + pushd ./src/knative.dev/${{ github.event.repository.name }} + ./hack/update-codegen.sh + popd + + - name: Verify + shell: bash + run: | + pushd ./src/knative.dev/${{ github.event.repository.name }} + if [[ -z "$(git status --porcelain)" ]]; then + echo "${{ github.repository }} up to date." + else + repoDiff=$(git diff-index --name-only HEAD --) + echo "Found diffs in: $repoDiff" + echo "${{ github.repository }} is out of date. Please run hack/update-codegen.sh" + exit 1 + fi + popd