Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/knative-donotsubmit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# 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.

# This file is automagically synced here from github.com/knative-sandbox/.github
# repo by knobots: https://github.com/mattmoor/knobots and will be overwritten.

name: Do Not Submit

on:
pull_request:
branches: [ 'master', 'release-*' ]

jobs:

donotsubmit:
name: Do Not Submit
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Do Not Submit
shell: bash
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ github.token }}
run: |
set -e
cd "${GITHUB_WORKSPACE}" || exit 1

TEMP_PATH="$(mktemp -d)"
PATH="${TEMP_PATH}:$PATH"

echo '::group::🐶 Installing reviewdog ... https://github.com/reviewdog/reviewdog'
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b "${TEMP_PATH}" 2>&1
echo '::endgroup::'

echo '::group:: Running DO NOT SUBMIT with reviewdog 🐶 ...'
# Don't fail because of grep
set +o pipefail
find . -type f -not -path './vendor/*' -not -path './third_party/*' -not -path './.git/*' -not -path './.github/workflows/*' |
xargs grep -n "DO NOT SUBMIT" |
reviewdog -efm="%f:%l:%m" \
-name="DO NOT SUBMIT" \
-reporter="github-pr-check" \
-filter-mode="added" \
-fail-on-error="true" \
-level="error"

echo '::endgroup::'
4 changes: 0 additions & 4 deletions .github/workflows/knative-go-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
name: Build

on:
push:
branches: [ 'master', 'release-*' ]
pull_request:
branches: [ 'master', 'release-*' ]

Expand All @@ -44,8 +42,6 @@ jobs:

- name: Check out code
uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Build
run: |
Expand Down
22 changes: 18 additions & 4 deletions .github/workflows/knative-go-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@
name: Test

on:

push:
branches: [ 'master', 'release-*' ]
branches: [ 'master' ]

pull_request:
branches: [ 'master', 'release-*' ]

jobs:

test:
name: Test
name: Unit Tests
strategy:
matrix:
go-version: [1.14.x]
Expand All @@ -44,8 +46,20 @@ jobs:

- name: Check out code
uses: actions/checkout@v2

- name: Check for .codecov.yaml
id: codecov-enabled
uses: andstor/file-existence-action@v1
with:
fetch-depth: 1
files: .codecov.yaml

- if: steps.codecov-enabled.outputs.files_exists == 'true'
name: Produce Go Coverage
run: echo '::set-env name=COVER_OPTS::-coverprofile=coverage.txt -covermode=atomic'

- name: Test
run: go test -race ./...
run: go test -race $COVER_OPTS ./...

- if: steps.codecov-enabled.outputs.files_exists == 'true'
name: Codecov
uses: codecov/codecov-action@v1
1 change: 1 addition & 0 deletions .github/workflows/knative-stale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# repo by knobots: https://github.com/mattmoor/knobots and will be overwritten.

name: 'Close stale'

on:
schedule:
- cron: '0 1 * * *'
Expand Down
166 changes: 142 additions & 24 deletions .github/workflows/knative-style.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
name: Code Style

on:
push:
branches: [ 'master', 'release-*' ]
pull_request:
branches: [ 'master', 'release-*' ]

jobs:

lint:
name: Lint
autoformat:
name: Auto-format and Check
runs-on: ubuntu-latest

steps:
Expand All @@ -39,65 +37,185 @@ jobs:

- name: Check out code
uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Install Dependencies
run: |
cd $(mktemp -d)
GO111MODULE=on go get golang.org/x/tools/cmd/goimports

# Run this last because it alters the workspace.
# TODO: add prettier step
# TODO: add goimports step
- name: Go Imports
shell: bash
run: |
goimports -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -name '*.pb.go' -prune -o -type f -name '*.go' -print)
echo "::set-env name=FMT_TOOL::goimports"
- name: Verify goimport
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 $FMT_TOOL."
exit 1
fi
echo "${{ github.repository }} is formatted correctly."

- 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
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -name '*.pb.go' -prune -o -type f -name '*.go' -print)
echo "::set-env name=FMT_TOOL::gofmt"
- name: Verify gofmt
shell: bash
# TODO(mattmoor): combine with above via anchors when actions support it.
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."
echo "${{ github.repository }} is out of style. Please run $FMT_TOOL."
exit 1
fi
echo "${{ github.repository }} is formatted correctly."

lint:
name: Lint
runs-on: ubuntu-latest

steps:

- name: Set up Go 1.14.x
uses: actions/setup-go@v2
with:
go-version: 1.14.x
id: go

- name: Check out code
uses: actions/checkout@v2

- name: Install Tools
run: |
TEMP_PATH="$(mktemp -d)"
cd $TEMP_PATH

echo '::group::🐶 Installing reviewdog ... https://github.com/reviewdog/reviewdog'
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b "${TEMP_PATH}" 2>&1
echo '::endgroup::'

echo '::group:: Installing misspell ... https://github.com/client9/misspell'
go get github.com/client9/misspell/cmd/misspell
echo '::endgroup::'

echo '::group:: Installing woke ... https://github.com/get-woke/woke'
curl -sfL https://raw.githubusercontent.com/get-woke/woke/main/install.sh | sh -s -- -b "${TEMP_PATH}" "${WOKE_VERSION}" 2>&1
echo '::endgroup::'

echo "::add-path::${TEMP_PATH}"

- id: golangci_configuration
uses: andstor/file-existence-action@v1
with:
files: .golangci.yaml

- name: Go Lint
if: steps.golangci_configuration.outputs.files_exists == 'true'
uses: golangci/golangci-lint-action@v2
with:
version: v1.30
only-new-issues: true # for initial defensiveness

# This is mostly copied from https://github.com/get-woke/woke-action-reviewdog/blob/main/entrypoint.sh
# since their action is not yet released under a stable version.
- name: Language
- name: misspell
shell: bash
if: ${{ always() }}
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ github.token }}
WOKE_VERSION: v0.1.11
run: |
set -e
cd "${GITHUB_WORKSPACE}" || exit 1

TEMP_PATH="$(mktemp -d)"
PATH="${TEMP_PATH}:$PATH"
echo '::group:: Running github.com/client9/misspell with reviewdog 🐶 ...'
# Don't fail because of misspell
set +o pipefail
find . -type f -not -path './vendor/*' -not -path './third_party/*' -not -path './.git/*' |
xargs misspell -error |
reviewdog -efm="%f:%l:%c: %m" \
-name="github.com/client9/misspell" \
-reporter="github-pr-check" \
-filter-mode="added" \
-fail-on-error="true" \
-level="error"

echo '::group::🐶 Installing reviewdog ... https://github.com/reviewdog/reviewdog'
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b "${TEMP_PATH}" 2>&1
echo '::endgroup::'

echo '::group:: Installing woke ... https://github.com/get-woke/woke'
curl -sfL https://raw.githubusercontent.com/get-woke/woke/main/install.sh | sh -s -- -b "${TEMP_PATH}" "${WOKE_VERSION}" 2>&1
- name: trailing whitespace
shell: bash
if: ${{ always() }}
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ github.token }}
run: |
set -e
cd "${GITHUB_WORKSPACE}" || exit 1

echo '::group:: Flagging trailing whitespace with reviewdog 🐶 ...'
# Don't fail because of grep
set +o pipefail
find . -type f -not -path './vendor/*' -not -path './third_party/*' -not -path './.git/*' |
xargs grep -nE " +$" |
reviewdog -efm="%f:%l:%m" \
-name="trailing whitespace" \
-reporter="github-pr-check" \
-filter-mode="added" \
-fail-on-error="true" \
-level="error"

echo '::endgroup::'

- name: EOF newline
shell: bash
if: ${{ always() }}
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ github.token }}
run: |
set -e
cd "${GITHUB_WORKSPACE}" || exit 1

echo '::group:: Flagging missing EOF newlines with reviewdog 🐶 ...'
# Don't fail because of misspell
set +o pipefail
for x in $(find . -type f -not -path './vendor/*' -not -path './third_party/*' -not -path './.git/*'); do
# Based on https://stackoverflow.com/questions/34943632/linux-check-if-there-is-an-empty-line-at-the-end-of-a-file
if [[ -f $x && ! ( -s "$x" && -z "$(tail -c 1 $x)" ) ]]; then
# We add 1 to `wc -l` here because of this limitation (from the man page):
# Characters beyond the final <newline> character will not be included in the line count.
echo $x:$((1 + $(wc -l $x | tr -s ' ' | cut -d' ' -f 1))): Missing newline
fi
done |
reviewdog -efm="%f:%l: %m" \
-name="EOF Newline" \
-reporter="github-pr-check" \
-filter-mode="added" \
-fail-on-error="true" \
-level="error"

echo '::endgroup::'

# This is mostly copied from https://github.com/get-woke/woke-action-reviewdog/blob/main/entrypoint.sh
# since their action is not yet released under a stable version.
- name: Language
if: ${{ always() && github.event_name == 'pull_request' }}
shell: bash
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ github.token }}
WOKE_VERSION: v0.1.11
run: |
set -e
cd "${GITHUB_WORKSPACE}" || exit 1

# Create a minimal .wokeignore if none already exist.
if [ ! -f .wokeignore ]; then
echo "vendor\nthird_party" > .wokeignore
cat > .wokeignore <<EOF
vendor/*
third_party/*
EOF
fi

echo '::group:: Running woke with reviewdog 🐶 ...'
Expand All @@ -107,5 +225,5 @@ jobs:
-reporter="github-pr-check" \
-filter-mode="added" \
-fail-on-error="true" \
-level="error" \
-level="error"
echo '::endgroup::'
3 changes: 0 additions & 3 deletions .github/workflows/knative-verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
name: Verify

on:
push:
branches: [ 'master', 'release-*' ]
pull_request:
branches: [ 'master', 'release-*' ]

Expand Down Expand Up @@ -53,7 +51,6 @@ jobs:
- name: Check out code onto GOPATH
uses: actions/checkout@v2
with:
fetch-depth: 1
path: ./src/knative.dev/${{ github.event.repository.name }}

- name: Update Codegen
Expand Down