Skip to content

Commit

Permalink
Automated Config Connector import.
Browse files Browse the repository at this point in the history
  - 539d66bbbeb39489f22b4539d571fb30f2286d12 Introduce validation GitHub action by Config Connector Team <no-reply@google.com>
  - 51c8cae5973b77171e6c84206c188d10d11e8693 Remove external folder by Config Connector Team <no-reply@google.com>

GitOrigin-RevId: 539d66bbbeb39489f22b4539d571fb30f2286d12
  • Loading branch information
Config Connector Team authored and copybara-github committed Aug 21, 2023
1 parent 2299b53 commit 27c79cc
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 4 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/presubmit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,32 @@ on:


jobs:
validations:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
with:
# This is introduced to make sure 'go generate' works properly
path: 'src/k8s-config-connector'
- uses: actions/setup-go@v4
with:
go-version: '1.19.11'
- name: 'Run validations'
run: |
cd ./src/k8s-config-connector
./scripts/github-actions/ga-validation.sh
env:
# This is introduced to make sure 'go generate' works properly
GOPATH: /home/runner/work/k8s-config-connector/k8s-config-connector
unit-tests:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v2
- uses: actions/setup-go@v4
with:
go-version: '^1.19.11'
go-version: '1.19.11'
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v1'
- name: 'Run unit tests'
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,9 @@ resource-docs:
run: generate fmt vet
SERVICE_MAPPING_DIR=config/servicemappings/ go run ./cmd/manager/main.go

# Ensures dependencies are up-to-date
.PHONY: ensure
ensure:
make -C third_party all
go mod tidy -compat=1.19

2 changes: 1 addition & 1 deletion scripts/fetch_ext_bins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set -o nounset
set -o pipefail

# needs KUBEBUILDER_VERSION
source $(dirname "${BASH_SOURCE}")/shared-vars.sh
source $(dirname "${BASH_SOURCE}")/shared-vars-public.sh

# Enable tracing in this script off by setting the TRACE variable in your
# environment to any value:
Expand Down
3 changes: 2 additions & 1 deletion scripts/generate-go-crd-clients/generate-clients.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ set -o nounset
set -o pipefail


source $(dirname "${BASH_SOURCE}")/../shared-vars-public.sh
REPO_ROOT="$(git rev-parse --show-toplevel)"
source ${REPO_ROOT}/scripts/shared-vars-public.sh
cd "${REPO_ROOT}/pkg/clients/generated/"

# Extract API & version names
Expand Down
26 changes: 26 additions & 0 deletions scripts/github-actions/ga-validation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
# Copyright 2023 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.
set -o errexit
set -o nounset
set -o pipefail
REPO_ROOT="$(git rev-parse --show-toplevel)"
source ${REPO_ROOT}/scripts/shared-vars-public.sh
cd ${REPO_ROOT}
source ${SCRIPT_DIR}/fetch_ext_bins.sh && \
fetch_tools && \
setup_envs

echo "Running validations..."
${SCRIPT_DIR}/validate-prereqs.sh
73 changes: 73 additions & 0 deletions scripts/validate-prereqs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash
# 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.
set -o errexit
set -o nounset
set -o pipefail
REPO_ROOT="$(git rev-parse --show-toplevel)"
cd "${REPO_ROOT}"

make fmt
changed_file_count=$(git diff --name-only | wc -l)
if [[ "${changed_file_count}" != "0" ]]; then
echo "Full diff:"
git diff
echo "ERROR: Files not formatted correctly. Please run 'make fmt' and patch your CL."
echo "Affected files:"
git diff --name-only
exit 1
fi
make generate
changed_file_count=$(git diff --name-only | wc -l)
if [[ "${changed_file_count}" != "0" ]]; then
echo "ERROR: Generated code out-of-date. Please run 'make generate' and patch your CL."
echo "Affected files:"
git diff --name-only
exit 1
fi
make manifests
changed_file_count=$(git diff --name-only | wc -l)
if [[ "${changed_file_count}" != "0" ]]; then
echo "ERROR: Manifests must be regenerated. Please run 'make manifests' and patch your CL."
echo "Affected files:"
git diff --name-only
exit 1
fi
make generate-go-client
changed_file_count=$(git diff --name-only | wc -l)
if [[ "${changed_file_count}" != "0" ]]; then
echo "ERROR: Resource Go Clients must be regenerated. Please run 'make generate-go-client' and patch your CL."
echo "Affected files:"
git diff --name-only
exit 1
fi
make ensure
if [[ $? -ne 0 ]]; then
echo "'make ensure' failed. Please validate the override patch files."
fi
changed_file_count=$(git diff --name-only | wc -l)
if [[ "${changed_file_count}" != "0" ]]; then
echo "ERROR: Vendored code does not match go.mod (+ override patches). Please run 'make ensure' and patch your CL."
echo "Affected files:"
git diff --name-only
exit 1
fi
make resource-docs
changed_file_count=$(git diff --name-only | wc -l)
if [[ "${changed_file_count}" != "0" ]]; then
echo "ERROR: Resource docs must be regenerated. Please run 'make resource-docs' and patch your CL."
echo "Affected files:"
git diff --name-only
exit 1
fi

0 comments on commit 27c79cc

Please sign in to comment.