Skip to content

Commit

Permalink
Merge branch 'master' into kubeval/v0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Mengqi Yu committed May 17, 2022
2 parents cd776ea + 9810263 commit 6092ce0
Show file tree
Hide file tree
Showing 641 changed files with 207,418 additions and 5,614 deletions.
64 changes: 32 additions & 32 deletions .github/workflows/checkSite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,35 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: CheckSite
on:
pull_request:
paths:
- "functions/**"
- "examples/**"
- "site/**"
- "scripts/generate_catalog/**"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Merge gob branch
run: git worktree add ./gob gob && cp -r gob/* .
- uses: actions/checkout@v2
with:
repository: etefera/href-checker
ref: docsify
path: href-checker
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install Site Checker
run: yarn install
working-directory: href-checker
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Run Site Checker
run: make site-check
# name: CheckSite
# on:
# pull_request:
# paths:
# - "functions/**"
# - "examples/**"
# - "site/**"
# - "scripts/generate_catalog/**"
# jobs:
# build:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# with:
# fetch-depth: 0
# - name: Merge gob branch
# run: git worktree add ./gob gob && cp -r gob/* .
# - uses: actions/checkout@v2
# with:
# repository: etefera/href-checker
# ref: docsify
# path: href-checker
# - uses: actions/setup-node@v2
# with:
# node-version: '16'
# - name: Install Site Checker
# run: yarn install
# working-directory: href-checker
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v1
# - name: Run Site Checker
# run: make site-check
23 changes: 16 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ on:
schedule:
- cron: '0 17 * * *'

concurrency:
# If a job with a concurrency group is running with cancel-in-progress, that job is cancelled when a new job with same concurrency group is started.
# In a workflow github.head_ref exists only for PRs while github.ref exists for the repo branches/tags.
# Concurrency group will be of form ${{ github.head_ref }}-ci when triggered via PR creating 1 group per PR. Older jobs are cancelled when new commits are pushed to that PR branch.
# Concurrency group will be of form ${{ github.ref }}-ci when triggered from repo branch or tag ref. Older jobs are cancelled when new jobs are triggered from that same branch/tag.
# `-ci` suffix is to namespace the concurrency group incase you want to add a group for another workflow in the future.
group: '${{ github.head_ref || github.ref }}-ci'
cancel-in-progress: true

jobs:
shell-ci:
strategy:
Expand All @@ -28,7 +37,7 @@ jobs:
strategy:
matrix:
platform: [ubuntu-latest]
node-version: [12.x]
node-version: [14.x]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
Expand All @@ -50,10 +59,10 @@ jobs:
GOPATH: /home/runner/work/kpt-functions-catalog/functions/go
GO111MODULE: on
steps:
- name: Set up Go 1.16
- name: Set up Go 1.17
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: 1.17
id: go
- name: Check out code into GOPATH
uses: actions/checkout@v1
Expand All @@ -72,7 +81,7 @@ jobs:
strategy:
matrix:
platform: [ubuntu-latest]
node-version: [12.x]
node-version: [14.x]
runs-on: ${{ matrix.platform }}
env:
GOPATH: /home/runner/work/kpt-functions-catalog/functions/go
Expand All @@ -83,13 +92,13 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Set up Go 1.16
- name: Set up Go 1.17
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: 1.17
- name: Install kpt
run: |
go get github.com/GoogleContainerTools/kpt@main
go install github.com/GoogleContainerTools/kpt@main
- name: Build node and Go docker images
if: matrix.platform == 'ubuntu-latest'
run: |
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2022 Google LLC
#
# 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: Create Short Tag for Function Release
on:
push:
tags:
# e.g. functions/go/apply-setters/v1.1.1
- "functions/*/*/v[0-9]+.[0-9]+.[0-9]+"
- "contrib/functions/*/*/v[0-9]+.[0-9]+.[0-9]+"

jobs:
build:
runs-on: ubuntu-latest
name: function-release
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Create Short Tag for Function Release
# Create secondary short tag, e.g. functions/go/apply-setters/v1.1.1 -> apply-setters/v1.1.1
run: |
export NEW_TAG=${GITHUB_REF#refs/tags/**functions/*/}
git tag -f "${NEW_TAG}" "${GITHUB_REF}"
git push origin "${NEW_TAG}"
7 changes: 3 additions & 4 deletions .github/workflows/verify-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ jobs:
- name: Install libs
run: |
pip install pyyaml
- name: Set up Go 1.16
- name: Set up Go 1.17
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: 1.17
- name: Install mdrip
run: |
go get github.com/russross/blackfriday/v2@v2.0.1
go get github.com/monopole/mdrip@v1.0.2
go install github.com/monopole/mdrip@v1.0.2
- name: Verify docs
run: |
make verify-docs
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @frankfarzan @mengqiy @droot @phanimarupaka
* @droot @mengqiy @sdowell @yuwenma
40 changes: 36 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ Contributions are required to follow these style guides:
│ │ └── ts: Home for all typescript-based contrib function source code
│ └── examples: Home for all contrib function examples.
├── scripts
└── tests: Home for e2e tests
├── tests: Home for e2e tests
└── build
└── docker
├── go: Home for default golang Dockerfile
│ └── Dockerfile
└── ts: Home for default typescript Dockerfile
└── Dockerfile
```

For each function, its files spread in the follow places:
Expand All @@ -70,12 +76,17 @@ For each function, its files spread in the follow places:
- golang-based functions should follow [this template][golang-template].
- typescript-based functions should follow [this template][ts-template].
- A metadata.yaml file that follows the function metadata schema.
- A Dockerfile to build the docker container.
- (Optional) A Dockerfile to build the docker container. If a Dockerfile is
not defined, the [default Dockerfile for the language][docker-common] will
be used.
- `examples/` directory: It contains examples for functions, and these examples
are also being tested as e2e tests. Each function should have at least one
example here. There must be a README.md file in each example directory, and it
should follow the [template][example-template].
- The `tests/` directory contains additional e2e tests.
- `master` branch should should contain examples with the `unstable` tag for
your function images. When you release the function version that tag should
have the samples and tests that match the function version.

For golang-based functions, you need to generate some doc related variables from
the `README.md` by running
Expand All @@ -95,6 +106,19 @@ To run all unit tests
$ make unit-test
```

#### Building a function image

To build all function images
```shell
$ make build
```

To build a single function image (e.g. `apply-setters`)
```shell
$ cd functions/go
$ make apply-setters-BUILD
```

#### E2E Tests

The e2e tests are the recommended way to test functions in the catalog. They are
Expand All @@ -105,11 +129,16 @@ structure [here][e2e test harness doc].
You can choose to put the e2e test in either the `examples/` directory or in the
`tests/` directory depending on if it is worthwhile to be shown as an example.

**Note**: The e2e tests don't build the images. So you need to ensure you have built
the latest image(s) before running any e2e tests.

To test a specific example or the e2e test, run

```shell
$ cd tests/e2etest
$ go test -v ./... -run TestE2E/../../examples/$EXAMPLE_NAME
# To test the example in contrib
$ go test -v ./... -run TestE2E/../../contrib/examples/$EXAMPLE_NAME
```

If you encounter some test failure saying something like "actual diff doesn't
Expand All @@ -119,6 +148,8 @@ expected `diff.patch` or `results.yaml` by running the following commands:
```shell
# Update one example
$ KPT_E2E_UPDATE_EXPECTED=true go test -v ./... -run TestE2E/../../examples/$EXAMPLE_NAME
# Update one example in contrib
$ KPT_E2E_UPDATE_EXPECTED=true go test -v ./... -run TestE2E/../../contrib/examples/$EXAMPLE_NAME

# Update all examples
$ KPT_E2E_UPDATE_EXPECTED=true go test -v ./...
Expand Down Expand Up @@ -152,8 +183,7 @@ pip install pyyaml
To install `mdrip`, run the following commands:

```shell
$ go get github.com/russross/blackfriday/v2@v2.0.1
$ go get github.com/monopole/mdrip@v1.0.2
$ go install github.com/monopole/mdrip@v1.0.2
```

And you need to ensure `$GOPATH/bin` is in your `PATH`.
Expand Down Expand Up @@ -196,6 +226,8 @@ Do you need a review or release of functions? We’d love to hear from you!

[ts-template]: https://raw.githubusercontent.com/GoogleContainerTools/kpt-functions-catalog/master/functions/ts/_template/README.md

[docker-common]: https://raw.githubusercontent.com/GoogleContainerTools/kpt-functions-catalog/master/build/docker

[example-template]: https://raw.githubusercontent.com/GoogleContainerTools/kpt-functions-catalog/master/examples/_template/README.md

[Slack channel]: https://kubernetes.slack.com/channels/kpt/
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ check-licenses:
cd contrib/functions/ts && $(MAKE) check-licenses

verify-docs:
GO111MODULE=on go get github.com/monopole/mdrip
go install github.com/monopole/mdrip@v1.0.2
(cd scripts/patch_reader/ && go build -o patch_reader .)
scripts/verify-docs.py

build: ## Build all function images. Variable 'TAG' is used to specify tag. 'dev' will be used if not set.
Expand All @@ -69,3 +70,7 @@ site-run: ## Run the site locally.
site-check: ## Test site for broken catalog links.
make site-run
./scripts/check-site.sh

update-function-docs: ## Update documentation for a function release branch
(cd scripts/update_function_docs/ && go build -o update_function_docs .)
RELEASE_BRANCH=$(RELEASE_BRANCH) ./scripts/update_function_docs/update_function_docs
33 changes: 33 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,38 @@ kpt-functions-catalog repo.
1. Click `Publish release` button.
1. Send an announcement email in the [kpt users google group].

## Updating function docs

After creating a release, the docs for the function should be updated to reflect
the latest patch version. A script has been created to automate this process.
The `RELEASE_BRANCH` branch should already exist in the [repo] and a tag should
be created on the [releases pages]. `RELEASE_BRANCH` is in the form of
`${FUNCTION_NAME}/v${MAJOR_VERSION}.${MINOR_VERSION}`.
For example `set-namespace/v0.3`, `kubeval/v0.1`, etc.


1. Run the script:
```shell
# Fetch from upstream (assuming upstream is set to official repo)
git fetch upstream
# Make sure local release branch is up to date
# e.g. git checkout set-namespace/v0.3 && git reset --hard upstream/set-namespace/v0.3
git checkout <RELEASE_BRANCH> && git reset --hard upstream/<RELEASE_BRANCH>
# Check out latest version of the make target from master
git checkout upstream/master
# Run the make target
# e.g. RELEASE_BRANCH=set-namespace/v0.3 make update-function-docs
RELEASE_BRANCH=<RELEASE_BRANCH> make update-function-docs
```
1. The script will generate a new commit in your local repository which updates
the docs for the provided function release. Push this commit to your remote.
```shell
# Push the commit to your remote (branch name can be anything)
# e.g. git push origin HEAD:update-docs-set-namespace
git push origin HEAD:<remote-branch>
```
1. Create a pull request targeted at the release branch.

[repo]: https://github.com/GoogleContainerTools/kpt-functions-catalog
[releases pages]: https://github.com/GoogleContainerTools/kpt-functions-catalog/releases
[kpt users google group]: https://groups.google.com/g/kpt-users
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.16-alpine3.13
FROM golang:1.17-alpine3.15
ENV CGO_ENABLED=0
WORKDIR /go/src/

Expand All @@ -10,7 +10,7 @@ RUN go build -o /usr/local/bin/function ./

#############################################

FROM alpine:3.13
FROM alpine:3.15
COPY --from=0 /usr/local/bin/function /usr/local/bin/function
ENTRYPOINT ["function"]

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:lts-alpine as builder
FROM node:14.19-alpine3.15 as builder

RUN mkdir -p /home/node/app && \
chown -R node:node /home/node/app
Expand All @@ -20,7 +20,10 @@ RUN npm run build && \

#############################################

FROM node:lts-alpine
FROM node:14.19-alpine3.15

ARG FILENAME
ENV FILENAME=${FILENAME}

# Run as non-root user as a best-practices:
# https://github.com/nodejs/docker-node/blob/master/docs/BestPractices.md
Expand All @@ -30,4 +33,4 @@ WORKDIR /home/node/app

COPY --from=builder /home/node/app /home/node/app

ENTRYPOINT ["node", "/home/node/app/dist/generate_folders_run.js"]
ENTRYPOINT node /home/node/app/dist/${FILENAME}
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
exitCode: 1
skip: true
Loading

0 comments on commit 6092ce0

Please sign in to comment.