Skip to content

Commit d1260fa

Browse files
author
ivanmkc
committed
Fixed issues with workflows
1 parent b9f8037 commit d1260fa

File tree

4 files changed

+52
-20
lines changed

4 files changed

+52
-20
lines changed

.github/workflows/go-pr-test.yaml renamed to .github/workflows/go-build-and-test.yaml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,5 @@ jobs:
2323
working-directory: ./examples/go
2424
run: go test ./...
2525

26-
- name: Run build_all.sh
27-
working-directory: ./examples/go/snippets
28-
run: ./build_all.sh
29-
30-
- name: Run run_all.sh
31-
working-directory: ./examples/go/snippets
32-
run: ./run_all.sh
26+
- name: Build Go snippets
27+
run: ./tools/go-snippets/runner.sh build

.github/workflows/go_snippets_test.yaml renamed to .github/workflows/go-snippets-pr-check.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@ jobs:
6666
echo "Building only the changed Go files..."
6767
./tools/go-snippets/runner.sh build ${{ steps.changed-files.outputs.changed_files }}
6868
69-
- name: Run changed Go snippets (PR only)
70-
if: github.event_name == 'pull_request' && steps.changed-files.outputs.changed_files != ''
71-
run: |
72-
echo "Running only the changed Go files..."
73-
./tools/go-snippets/runner.sh run ${{ steps.changed-files.outputs.changed_files }}
74-
7569
# --- Scheduled Checks ---
7670
# These steps only run on the weekly schedule.
7771

@@ -80,9 +74,3 @@ jobs:
8074
run: |
8175
echo "Running weekly build for all Go snippets..."
8276
./tools/go-snippets/runner.sh build
83-
84-
- name: Run all Go snippets (Scheduled)
85-
if: github.event_name == 'schedule'
86-
run: |
87-
echo "Running weekly run for all Go snippets..."
88-
./tools/go-snippets/runner.sh run
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
# Copyright 2025 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# This script ensures that every .go file within the Go snippets directory
17+
# is referenced in the files_to_test.txt file. This prevents new snippets
18+
# from being added without being included in the regression test suite.
19+
20+
# --- Configuration ---
21+
RED='\033[0;31m'
22+
NC='\033[0m' # No Color
23+
EXIT_CODE=0
24+
SNIPPETS_FILE="tools/go-snippets/files_to_test.txt"
25+
26+
# --- Logic ---
27+
echo "Checking for Go files that are not registered in ${SNIPPETS_FILE}..."
28+
29+
# Find all .go files in the snippets directory, excluding _test.go files.
30+
all_go_files=$(find examples/go -type f -name "*.go" ! -name "*_test.go" | sed 's|examples/go/||' | sort)
31+
32+
# Extract all .go file paths from the snippets file, ignoring comments and arguments.
33+
referenced_files=$(grep -v '^\s*#' "${SNIPPETS_FILE}" | grep -o '[a-zA-Z0-9/._-]*\.go' | sort | uniq)
34+
35+
# Compare the list of all .go files with the list of referenced files.
36+
unreferenced_files=$(comm -23 <(echo "${all_go_files}") <(echo "${referenced_files}"))
37+
38+
if [[ -n "${unreferenced_files}" ]]; then
39+
echo -e "${RED}Error: The following Go files were found but are not referenced in ${SNIPPETS_FILE}:${NC}"
40+
# Indent the list of files for readability.
41+
echo "${unreferenced_files}" | sed 's/^/ /'
42+
echo
43+
echo "Please add them to ${SNIPPETS_FILE} to include them in the regression tests."
44+
EXIT_CODE=1
45+
else
46+
echo "All Go files are correctly referenced in the snippets file."
47+
fi
48+
49+
exit ${EXIT_CODE}

tools/go-snippets/runner.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ execute_and_check() {
6363
if [[ "$1" != "build" && "$1" != "run" ]]; then
6464
echo "Usage: $0 <build|run> [file1 file2 ...]"
6565
exit 1
66-
}
66+
fi
6767

6868
ACTION=$1
6969
shift

0 commit comments

Comments
 (0)