diff --git a/.github/workflows/go-build.yml b/.github/workflows/go-build.yml new file mode 100644 index 00000000..315741b5 --- /dev/null +++ b/.github/workflows/go-build.yml @@ -0,0 +1,42 @@ +name: Build + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + + build: + name: Build + strategy: + matrix: + go-version: [1.13.x, 1.14.x] + platform: [ubuntu-latest] + + runs-on: ${{ matrix.platform }} + + env: + GOPATH: ${{ github.workspace }} + GO111MODULE: off + + steps: + + - name: Set up Go ${{ matrix.go-version }} + uses: actions/setup-go@v1 + with: + go-version: ${{ matrix.go-version }} + id: go + + - name: Check out code onto GOPATH + uses: actions/checkout@v2 + with: + fetch-depth: 1 + path: ./src/github.com/${{ github.repository }} + + - name: Vet + run: go vet github.com/${{ github.repository }}/... + + - name: Build + run: go build -v github.com/${{ github.repository }}/... diff --git a/.github/workflows/go-style.yml b/.github/workflows/go-style.yml new file mode 100644 index 00000000..991f7ee9 --- /dev/null +++ b/.github/workflows/go-style.yml @@ -0,0 +1,53 @@ +name: Code Style + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + + lint: + name: Lint + runs-on: ubuntu-latest + + env: + GOPATH: ${{ github.workspace }} + GO111MODULE: off + + steps: + + - name: Set up Go 1.13.x + uses: actions/setup-go@v1 + with: + go-version: 1.13.x + id: go + + - name: Check out code onto GOPATH + uses: actions/checkout@v2 + with: + fetch-depth: 1 + path: ./src/github.com/${{ github.repository }} + +# TODO: add pretter step + + - name: Go Format + shell: bash + run: | + pushd ./src/github.com/${{ github.repository }} + gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print) + popd + + - name: Verify + shell: bash + run: | + pushd ./src/github.com/${{ github.repository }} + 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." + popd diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml new file mode 100644 index 00000000..ca5ee72e --- /dev/null +++ b/.github/workflows/go-test.yml @@ -0,0 +1,39 @@ +name: Test + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + + test: + name: Test + strategy: + matrix: + go-version: [1.13.x, 1.14.x] + platform: [ubuntu-latest] + + runs-on: ${{ matrix.platform }} + + env: + GOPATH: ${{ github.workspace }} + GO111MODULE: off + + steps: + + - name: Set up Go ${{ matrix.go-version }} + uses: actions/setup-go@v1 + with: + go-version: ${{ matrix.go-version }} + id: go + + - name: Check out code onto GOPATH + uses: actions/checkout@v2 + with: + fetch-depth: 1 + path: ./src/github.com/${{ github.repository }} + + - name: Test + run: go test -race github.com/${{ github.repository }}/... diff --git a/.github/workflows/go-verify.yml b/.github/workflows/go-verify.yml new file mode 100644 index 00000000..3ade6130 --- /dev/null +++ b/.github/workflows/go-verify.yml @@ -0,0 +1,71 @@ +name: Verify + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + + verify: + name: Verify Deps and Codegen + strategy: + matrix: + go-version: [1.13.x, 1.14.x] + platform: [ubuntu-latest] + + runs-on: ${{ matrix.platform }} + + env: + GOPATH: ${{ github.workspace }} + GO111MODULE: off + + steps: + + - name: Set up Go ${{ matrix.go-version }} + uses: actions/setup-go@v1 + with: + go-version: ${{ matrix.go-version }} + id: go + + - name: Add GOPATH/bin to PATH + shell: bash + run: | + echo "::set-env name=GOPATH::$(go env GOPATH)" + echo "::add-path::$(go env GOPATH)/bin" + + - name: Install Dependencies + run: | + go get github.com/golang/dep/cmd/dep + go get github.com/google/ko/cmd/ko + go get github.com/google/licenseclassifier + go get github.com/google/go-licenses + go get knative.dev/test-infra/tools/dep-collector + + - name: Check out code onto GOPATH + uses: actions/checkout@v2 + with: + fetch-depth: 2 + path: ./src/github.com/${{ github.repository }} + + - name: Update Codegen + shell: bash + run: | + pushd ./src/github.com/${{ github.repository }} + ./hack/update-codegen.sh + popd + + - name: Verify + shell: bash + run: | + pushd ./src/github.com/${{ github.repository }} + 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 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..b494ec01 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,67 @@ +on: + push: + # Sequence of patterns matched against refs/tags + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +name: Create Release + +jobs: + + ko-resolve: + name: Release ko artifact + runs-on: ubuntu-latest + env: + GOPATH: ${{ github.workspace }} + GO111MODULE: off + KO_DOCKER_REPO: docker.io/n3wscott + + steps: + - name: Set up Go 1.13.x + uses: actions/setup-go@v1 + with: + go-version: 1.13.x + + - name: Add GOPATH/bin to PATH + shell: bash + run: | + echo "::set-env name=GOPATH::$(go env GOPATH)" + echo "::add-path::$(go env GOPATH)/bin" + + - name: Setup ko + run: | + GO111MODULE=on go get github.com/google/ko/cmd/ko + docker login -u n3wscott -p ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Check out code onto GOPATH + uses: actions/checkout@v2 + with: + fetch-depth: 1 + path: ./src/github.com/${{ github.repository }} + + - name: Build and Publish images, Produce release artifact. + working-directory: ./src/github.com/${{ github.repository }} + run: | + ko resolve --tags $(basename "${{ github.ref }}" ) -BRf config/ > release.yaml + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: true + + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./src/github.com/${{ github.repository }}/release.yaml + asset_name: release.yaml + asset_content_type: text/plain