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

Add schema validation for configuration-matrix files #26081

Merged
merged 2 commits into from
Jun 12, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/actions/ginkgo/focus-schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
focus: list(str())
include: list(include('includeItem'))
exclude: list(include('excludeItem'))
---
includeItem:
focus: str()
cliFocus: str()
cliSkip: str(required=False)
excludeItem:
k8s-version: str()
focus: str()
7 changes: 7 additions & 0 deletions .github/actions/ginkgo/k8s-versions-schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include: list(include('includeItem'))
---
includeItem:
k8s-version: str()
ip-family: str()
kube-image: str()
kernel: str()
1 change: 1 addition & 0 deletions .github/actions/ginkgo/prs-schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
k8s-version: list(str())
1 change: 1 addition & 0 deletions .github/actions/ginkgo/scheduled-schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
k8s-version: list(str())
121 changes: 0 additions & 121 deletions .github/workflows/lint-go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,124 +121,3 @@ jobs:

cd src/github.com/cilium/cilium
contrib/scripts/check-k8s-code-gen.sh

ginkgo-workflow-comments:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with:
persist-credentials: false
# hard-code the path instead of using ${{ github.repository }} to make sure it works for forked repo as well
path: src/github.com/cilium/cilium

# Load Ginkgo build from GitHub
- name: Load ginkgo linter from GH cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
id: cache
with:
path: /tmp/.ginkgo-build/
key: ${{ runner.os }}-ginkgo-linter-${{ hashFiles('src/github.com/cilium/cilium/**/*.go') }}

- name: Install Go
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
# renovate: datasource=golang-version depName=go
go-version: 1.20.4

- name: Build Ginkgo
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
cd src/github.com/cilium/cilium
go install github.com/onsi/ginkgo/ginkgo@v1.16.5
mkdir -p /tmp/.ginkgo-build

- name: Building Ginkgo Linter Test
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
cd src/github.com/cilium/cilium
git apply contrib/testing/ginkgo-get-all-test-names.patch

cd test
/home/runner/go/bin/ginkgo build
strip test.test
tar -cz test.test -f test.tgz

- name: Store Ginkgo Linter Test in GitHub cache path
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
cd src/github.com/cilium/cilium
mkdir -p /tmp/.ginkgo-build/
if [ -f test/test.tgz ]; then
cp test/test.tgz /tmp/.ginkgo-build/
echo "file copied"
fi

- name: Copy Ginkgo binary
if: ${{ steps.cache.outputs.cache-hit == 'true' }}
shell: bash
run: |
cd src/github.com/cilium/cilium/test/
tar -xf /tmp/.ginkgo-build/test.tgz

- name: Reading Comments From Workflows
shell: bash
run: |
cd src/github.com/cilium/cilium

grep '# K8s' .github/actions/ginkgo/main-focus.yaml | \
sed -e 's/^[[:space:]]\+# //g' | \
sort -u > /tmp/ginkgo-workflow-comments.txt

grep '# Runtime' .github/workflows/conformance-runtime.yaml | \
sed -e 's/^[[:space:]]\+# //g' | \
sort -u > /tmp/runtime-workflow-comments.txt

- name: Getting test runs output
shell: bash
run: |
cd src/github.com/cilium/cilium/test

./test.test -ginkgo.failFast -ginkgo.dryRun -- --cilium.testScope=K8s | \
grep TestRun | \
grep -v 'TestRun\[Top Level\] Runtime' | \
sed 's/TestRun\[Top Level\]\ //g' | \
sort -u > /tmp/ginkgo-tests.txt

./test.test -ginkgo.failFast -ginkgo.dryRun -- --cilium.testScope=Runtime | \
grep TestRun | \
grep -v 'TestRun\[Top Level\] K8s' | \
sed 's/TestRun\[Top Level\]\ //g' | \
sort -u > /tmp/runtime-tests.txt

- name: Checking diff Ginkgo Workflow
shell: bash
run: |
diff /tmp/ginkgo-workflow-comments.txt /tmp/ginkgo-tests.txt --suppress-common-lines

if [ $? -ne 0 ]; then
echo ""
echo "Ginkgo tests out of sync with comments from GH workflow:"
echo "$diff"
echo "Please fix the comments from .github/actions/ginkgo/main-focus.yaml accordingly"
echo ""
exit 1
fi

- name: Checking diff Runtime Workflow
shell: bash
run: |
diff /tmp/runtime-workflow-comments.txt /tmp/runtime-tests.txt --suppress-common-lines

if [ $? -ne 0 ]; then
echo ""
echo "Ginkgo tests out of sync with comments from GH workflow:"
echo "$diff"
echo ""
echo "Please fix the comments from .github/workflows/conformance-runtime.yaml accordingly"
exit 1
fi
159 changes: 159 additions & 0 deletions .github/workflows/lint-workflows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
name: GitHub Workflow-related checks

# Any change in triggers needs to be reflected in the concurrency group.
on:
pull_request: {}
push:
branches:
- main
- ft/main/**

permissions: read-all

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after }}
cancel-in-progress: true

jobs:
ginkgo-workflow-comments:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with:
persist-credentials: false
# hard-code the path instead of using ${{ github.repository }} to make sure it works for forked repo as well
path: src/github.com/cilium/cilium

# Load Ginkgo build from GitHub
- name: Load ginkgo linter from GH cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
id: cache
with:
path: /tmp/.ginkgo-build/
key: ${{ runner.os }}-ginkgo-linter-${{ hashFiles('src/github.com/cilium/cilium/**/*.go') }}

- name: Install Go
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
# renovate: datasource=golang-version depName=go
go-version: 1.20.4

- name: Build Ginkgo
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
cd src/github.com/cilium/cilium
go install github.com/onsi/ginkgo/ginkgo@v1.16.5
mkdir -p /tmp/.ginkgo-build

- name: Building Ginkgo Linter Test
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
cd src/github.com/cilium/cilium
git apply contrib/testing/ginkgo-get-all-test-names.patch

cd test
/home/runner/go/bin/ginkgo build
strip test.test
tar -cz test.test -f test.tgz

- name: Store Ginkgo Linter Test in GitHub cache path
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
cd src/github.com/cilium/cilium
mkdir -p /tmp/.ginkgo-build/
if [ -f test/test.tgz ]; then
cp test/test.tgz /tmp/.ginkgo-build/
echo "file copied"
fi

- name: Copy Ginkgo binary
if: ${{ steps.cache.outputs.cache-hit == 'true' }}
shell: bash
run: |
cd src/github.com/cilium/cilium/test/
tar -xf /tmp/.ginkgo-build/test.tgz

- name: Reading Comments From Workflows
shell: bash
run: |
cd src/github.com/cilium/cilium

grep '# K8s' .github/actions/ginkgo/main-focus.yaml | \
sed -e 's/^[[:space:]]\+# //g' | \
sort -u > /tmp/ginkgo-workflow-comments.txt

grep '# Runtime' .github/workflows/conformance-runtime.yaml | \
sed -e 's/^[[:space:]]\+# //g' | \
sort -u > /tmp/runtime-workflow-comments.txt

- name: Getting test runs output
shell: bash
run: |
cd src/github.com/cilium/cilium/test

./test.test -ginkgo.failFast -ginkgo.dryRun -- --cilium.testScope=K8s | \
grep TestRun | \
grep -v 'TestRun\[Top Level\] Runtime' | \
sed 's/TestRun\[Top Level\]\ //g' | \
sort -u > /tmp/ginkgo-tests.txt

./test.test -ginkgo.failFast -ginkgo.dryRun -- --cilium.testScope=Runtime | \
grep TestRun | \
grep -v 'TestRun\[Top Level\] K8s' | \
sed 's/TestRun\[Top Level\]\ //g' | \
sort -u > /tmp/runtime-tests.txt

- name: Checking diff Ginkgo Workflow
shell: bash
run: |
diff /tmp/ginkgo-workflow-comments.txt /tmp/ginkgo-tests.txt --suppress-common-lines

if [ $? -ne 0 ]; then
echo ""
echo "Ginkgo tests out of sync with comments from GH workflow:"
echo "$diff"
echo "Please fix the comments from .github/actions/ginkgo/main-focus.yaml accordingly"
echo ""
exit 1
fi

- name: Checking diff Runtime Workflow
shell: bash
run: |
diff /tmp/runtime-workflow-comments.txt /tmp/runtime-tests.txt --suppress-common-lines

if [ $? -ne 0 ]; then
echo ""
echo "Ginkgo tests out of sync with comments from GH workflow:"
echo "$diff"
echo ""
echo "Please fix the comments from .github/workflows/conformance-runtime.yaml accordingly"
exit 1
fi

ginkgo-schema-validation:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@bd6b4b6205c4dbad673328db7b31b7fab9e241c0 # v4.6.1
with:
python-version: '3.10'
- run: pip install yamale
- name: Checkout code
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with:
persist-credentials: false
# hard-code the path instead of using ${{ github.repository }} to make sure it works for forked repo as well
path: src/github.com/cilium/cilium

- name: Validate schema of ginkgo action files
shell: bash
run: |
cd src/github.com/cilium/cilium/.github/actions/ginkgo/
for type in focus k8s-versions prs scheduled; do
yamale -s ${type}-schema.yaml *-${type}.yaml;
done