Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter github actions to be executed #5846

Merged
merged 2 commits into from
Jul 4, 2020
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
81 changes: 75 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,54 @@ on:
pull_request:
branches:
- "*"

push:
branches:
- master

jobs:

changes:
runs-on: ubuntu-latest
outputs:
go: ${{ steps.filter.outputs.go }}
charts: ${{ steps.filter.outputs.charts }}

steps:

- name: Checkout
uses: actions/checkout@v1

- uses: dorny/[email protected]
id: filter
with:
token: ${{ secrets.GITHUB_TOKEN }}
filters: |
go:
- '**/*.go'
- 'go.mod'
- 'go.sum'
- 'rootfs/**/*'
charts:
- 'charts/ingress-nginx/Chart.yaml'
- 'charts/ingress-nginx/*'

build:
name: Build
runs-on: ubuntu-latest
needs: changes
if: ${{ needs.changes.outputs.go == 'true' }}

steps:

- name: Checkout
uses: actions/checkout@v1

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

- name: Checkout
uses: actions/checkout@v1

- name: Set up Docker Buildx
id: buildx
Expand Down Expand Up @@ -63,15 +93,55 @@ jobs:
name: docker.tar.gz
path: docker.tar.gz

helm:
name: Helm chart
runs-on: ubuntu-latest
needs:
- changes
if: ${{ needs.changes.outputs.charts == 'true' }}

steps:

- name: Checkout
uses: actions/checkout@v1

- name: Lint
run: |
./build/run-in-docker.sh ./hack/verify-chart-lint.sh

- name: fix permissions
run: |
sudo mkdir -p $HOME/.kube
sudo chmod -R 777 $HOME/.kube

- name: Create Kubernetes cluster
id: kind
uses: engineerd/[email protected]
with:
version: v0.8.1
image: kindest/node:v1.18.4

- name: Test
env:
KIND_CLUSTER_NAME: kind
SKIP_CLUSTER_CREATION: true
run: |
kind get kubeconfig > $HOME/.kube/kind-config-kind
make kind-e2e-chart-tests

kubernetes:
name: Kubernetes
runs-on: ubuntu-latest
needs: build
needs:
- changes
- build
if: ${{ needs.changes.outputs.go == 'true' }}
strategy:
matrix:
k8s: [v1.14.10, v1.15.11, v1.16.9, v1.17.5, v1.18.4]

steps:

- name: Checkout
uses: actions/checkout@v1

Expand All @@ -88,7 +158,6 @@ jobs:
config: test/e2e/kind.yaml
image: kindest/node:${{ matrix.k8s }}

# delete-artifact
- uses: geekyeggo/delete-artifact@v1
with:
name: docker.tar.gz
Expand Down
29 changes: 28 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,31 @@ on:

jobs:

changes:
runs-on: ubuntu-latest
outputs:
go: ${{ steps.filter.outputs.go }}
charts: ${{ steps.filter.outputs.charts }}
steps:
- name: Checkout
uses: actions/checkout@v1

- uses: dorny/[email protected]
id: filter
with:
token: ${{ secrets.GITHUB_TOKEN }}
filters: |
docs:
- 'docs/**/*'
charts:
- 'charts/ingress-nginx/Chart.yaml'

docs:
name: Update Documentation
runs-on: ubuntu-latest
needs:
- changes
if: ${{ needs.changes.outputs.docs == 'true' }}
steps:
- name: Checkout master
uses: actions/checkout@v1
Expand All @@ -19,8 +42,12 @@ jobs:
PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}

chart:
needs: docs
name: Release Chart
runs-on: ubuntu-latest
needs:
- changes
if: ${{ needs.changes.outputs.charts == 'true' }}

steps:
- name: Checkout master
uses: actions/checkout@v1
Expand Down
37 changes: 24 additions & 13 deletions test/e2e/run-chart-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,38 @@ fi

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

export K8S_VERSION=${K8S_VERSION:-v1.18.4@sha256:d8ff5fc405fc679dd3dd0cccc01543ba4942ed90823817d2e9e2c474a5343c4f}
export KIND_CLUSTER_NAME=${KIND_CLUSTER_NAME:-ingress-nginx-dev}

KIND_CLUSTER_NAME="ingress-nginx-dev"
export KUBECONFIG="${KUBECONFIG:-$HOME/.kube/kind-config-$KIND_CLUSTER_NAME}"

echo "[dev-env] creating Kubernetes cluster with kind"
export KUBECONFIG="${HOME}/.kube/kind-config-${KIND_CLUSTER_NAME}"
kind create cluster \
--name ${KIND_CLUSTER_NAME} \
--config "${DIR}/kind.yaml" \
--retain \
--image "kindest/node:${K8S_VERSION}"
# Disable execution if running as a Prow job
if [[ ! -z ${PROW_JOB_ID:-} ]]; then
echo "skipping execution..."
exit 0
fi

if [ "${SKIP_CLUSTER_CREATION:-false}" = "false" ]; then
echo "[dev-env] creating Kubernetes cluster with kind"

export K8S_VERSION=${K8S_VERSION:-v1.18.4@sha256:d8ff5fc405fc679dd3dd0cccc01543ba4942ed90823817d2e9e2c474a5343c4f}

echo "Kubernetes cluster:"
kubectl get nodes -o wide
kind create cluster \
--verbosity=${KIND_LOG_LEVEL} \
--name ${KIND_CLUSTER_NAME} \
--config ${DIR}/kind.yaml \
--retain \
--image "kindest/node:${K8S_VERSION}"

echo "Kubernetes cluster:"
kubectl get nodes -o wide
fi

echo "[dev-env] running helm chart e2e tests..."
docker run --rm --interactive --network host \
--name ct \
--volume $KUBECONFIG:/root/.kube/config \
--volume "${DIR}/../../":/workdir \
--workdir /workdir \
quay.io/helmpack/chart-testing:v3.0.0-rc.1 ct install \
aledbf/chart-testing:v3.0.0-rc.4 ct install \
--charts charts/ingress-nginx \
--helm-extra-args "--timeout 120s"
--helm-extra-args "--timeout 60s"
3 changes: 1 addition & 2 deletions test/e2e/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ trap cleanup EXIT

export KIND_CLUSTER_NAME=${KIND_CLUSTER_NAME:-ingress-nginx-dev}

export KIND_CLUSTER_NAME=${KIND_CLUSTER_NAME:-ingress-nginx-dev}

# Disable execution if running as a Prow job
if [[ ! -z ${PROW_JOB_ID:-} ]]; then
echo "skipping execution..."
exit 0
Expand Down