Skip to content

Commit

Permalink
[master] Update GitHub Actions (#3972)
Browse files Browse the repository at this point in the history
Copied from `https://github.com/knative/.github/tree/master/workflow-templates`.
/assign grantr matzew n3wscott
/cc grantr matzew n3wscott
  • Loading branch information
mattmoor authored Aug 31, 2020
1 parent 8523245 commit 1b8b850
Show file tree
Hide file tree
Showing 5 changed files with 257 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/knative-go-build.yaml
Original file line number Diff line number Diff line change
@@ -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 ./...
46 changes: 46 additions & 0 deletions .github/workflows/knative-go-test.yaml
Original file line number Diff line number Diff line change
@@ -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 ./...
31 changes: 31 additions & 0 deletions .github/workflows/knative-stale.yaml
Original file line number Diff line number Diff line change
@@ -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
57 changes: 57 additions & 0 deletions .github/workflows/knative-style.yaml
Original file line number Diff line number Diff line change
@@ -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."
74 changes: 74 additions & 0 deletions .github/workflows/knative-verify.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1b8b850

Please sign in to comment.