Skip to content

Commit

Permalink
Update common github actions (ko-build#242)
Browse files Browse the repository at this point in the history
Signed-off-by: Knative Automation <automation@knative.team>
  • Loading branch information
knative-automation authored Nov 5, 2020
1 parent 1f17ce9 commit 36a921f
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 5 deletions.
21 changes: 19 additions & 2 deletions .github/workflows/knative-releasability.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
# The following pushes the stdout of buoy into $CHECK_MESSAGE
CHECK=0
echo 'CHECK_MESSAGE<<EOF' >> $GITHUB_ENV
buoy check go.mod --release ${RELEASE} --domain knative.dev --verbose >> $GITHUB_ENV || CHECK=$?
buoy check go.mod --release ${RELEASE} --domain knative.dev --verbose >> $GITHUB_ENV 2>&1 || CHECK=$?
echo 'EOF' >> $GITHUB_ENV
# We just captured the return code of the buoy call, test it to see
Expand All @@ -104,8 +104,25 @@ jobs:
- name: Verify
if: steps.exists.outputs.release-branch == 'false' && env.current == 'true'
run: |
# If we don't run `git status` before the "git diff-index" it seems
# to list every file that's been touched by codegen.
git status
FOUND_DIFF=0
for x in $(git diff-index --name-only HEAD --); do
if [ "$(basename $x)" = "go.mod" ]; then
continue
elif [ "$(basename $x)" = "go.sum" ]; then
continue
elif [ "$(basename $x)" = "modules.txt" ]; then
continue
fi
echo "Found non-module diff: $x"
FOUND_DIFF=1
break
done
# If we see no changes after the upgrade, then we are up to date.
if [[ -z "$(git status --porcelain)" ]]; then
if [[ "$FOUND_DIFF" -eq "0" ]]; then
echo "VERIFY_MESSAGE=${{ github.repository }} up to date." >> $GITHUB_ENV
else
echo "VERIFY_MESSAGE=${{ github.repository }} is out of date." >> $GITHUB_ENV
Expand Down
96 changes: 96 additions & 0 deletions .github/workflows/knative-release-notes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# 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/knative-sandbox/knobots and will be overwritten.

name: 'Release Notes'

on:
workflow_dispatch:
inputs:
branch:
description: 'Branch? (master)'
required: true
default: 'master'
start-sha:
description: 'Starting SHA? (last tag on branch)'
end-sha:
description: 'Ending SHA? (latest HEAD)'

jobs:
release-notes:
name: Release Notes
runs-on: 'ubuntu-latest'

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

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

- name: Install Dependencies
run: GO111MODULE=on go get k8s.io/release/cmd/release-notes

- name: Check out code
uses: actions/checkout@v2
with:
# fetch-depth of 0 indicates all history for all branches and tags.
fetch-depth: 0

# Note: Defaults needs to run after we check out the repo.
- name: Defaults
run: |
echo ORG=$(echo '${{ github.repository }}' | awk -F '/' '{print $1}') >> $GITHUB_ENV
echo REPO=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}') >> $GITHUB_ENV
echo "BRANCH=${{ github.event.inputs.branch }}" >> $GITHUB_ENV
if [[ "${{ github.event.inputs.start-sha }}" != "" ]]; then
echo "START_SHA=${{ github.event.inputs.start-sha }}" >> $GITHUB_ENV
else
# Default Starting SHA (thanks @dprotaso)
export semver=$(git describe --match "v[0-9]*" --abbrev=0)
echo "Using ${semver} tag for starting sha."
echo START_SHA=$(git rev-list -n 1 "${semver}") >> $GITHUB_ENV
fi
if [[ "${{ github.event.inputs.end-sha }}" != "" ]]; then
echo "END_SHA=${{ github.event.inputs.end-sha }}" >> $GITHUB_ENV
else
# Default Ending SHA (thanks @dprotaso)
echo "END_SHA=$(git rev-list -n 1 HEAD)" >> $GITHUB_ENV
fi
- name: Generate Notes
run: |
# See https://github.com/kubernetes/release/tree/master/cmd/release-notes for options.
# Note: we are setting env vars in the Defaults step.
release-notes \
--required-author "" \
--repo-path "$(pwd)" \
--output release-notes.md
- name: Display Notes
run: |
cat release-notes.md
- name: Archive Release Notes
uses: actions/upload-artifact@v2
with:
name: release-notes.md
path: release-notes.md
14 changes: 11 additions & 3 deletions .github/workflows/knative-style.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,14 @@ jobs:
- name: ${{ matrix.tool }} ${{ matrix.options }}
shell: bash
run: |
${{ matrix.tool }} ${{ matrix.options }} -w $(find . -path './vendor' -prune -o -path './third_party' -prune -o -name '*.pb.go' -prune -o -type f -name '*.go' -print)
run: >
${{ matrix.tool }} ${{ matrix.options }} -w
$(find .
-path './vendor' -prune
-o -path './third_party' -prune
-o -name '*.pb.go' -prune
-o -name 'wire_gen.go' -prune
-o -type f -name '*.go' -print)
- name: Verify ${{ matrix.tool }}
shell: bash
Expand Down Expand Up @@ -239,7 +245,9 @@ jobs:
elif echo $ch | grep --quiet -E "fmt\." ; then # all other fmt. printers.
err=$(echo $ch | sed -E 's/(fmt\.)(Print|Fprint)f([^%]+) (%[^sTxq]",)([^,]+)/\1\2\3",\5/')
fi
echo "$file:$line: Please consider avoiding tail format like this:%0A$err"
# Trim spaces.
ch=$(echo $ch | xargs)
echo "$file:$line: Please consider avoiding tail format like this:%0A- $ch%0A+ $err"
done |
reviewdog -efm="%f:%l: %m" \
-name="Redundant Format" \
Expand Down

0 comments on commit 36a921f

Please sign in to comment.