From 53d37ad608e1465d78a6c990a871f47fc5ae7bee Mon Sep 17 00:00:00 2001 From: Tomo Suzuki Date: Mon, 10 Oct 2022 09:15:09 -0400 Subject: [PATCH 1/4] ci: added gitignore check --- .github/workflows/generated_files_sync.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/generated_files_sync.yaml b/.github/workflows/generated_files_sync.yaml index aafe64fe7cfb..01addf54d74b 100644 --- a/.github/workflows/generated_files_sync.yaml +++ b/.github/workflows/generated_files_sync.yaml @@ -95,3 +95,22 @@ jobs: bash generation/update_owlbot_postprocessor_config.sh - name: Fail if there's any difference run: git --no-pager diff --exit-code + + gitignore_correctness: + name: Generated files should not match gitignore + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: checking any files matching gitignore + shell: bash + run: | + find . -type f -name '*.java' -not -path './.git/*' \ + |git check-ignore --no-index --verbose --stdin + if [ "$?" == 1 ]; then + echo "No matching files. Good." + exit 0 + else + echo "There are gitignore matching files. Please adjust .gitignore." + exit 1 + fi + From aa8d16f8315120ea6851a7c117cf18aa835b6baa Mon Sep 17 00:00:00 2001 From: Tomo Suzuki Date: Mon, 10 Oct 2022 09:19:56 -0400 Subject: [PATCH 2/4] fix: fixed gitignore --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index 08c8434fbbf1..ae47eb44dee0 100644 --- a/.gitignore +++ b/.gitignore @@ -48,9 +48,6 @@ nosetests.xml .DS_Store .classpath -# Built documentation -docs/ - # API key file containing value of GOOGLE_API_KEY for integration tests api_key From 64daa4c3506f88a159f30a31f852c63cdd76d462 Mon Sep 17 00:00:00 2001 From: Tomo Suzuki Date: Mon, 10 Oct 2022 09:23:34 -0400 Subject: [PATCH 3/4] not to fail upon git check-ignore return code 1 --- .github/workflows/generated_files_sync.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/generated_files_sync.yaml b/.github/workflows/generated_files_sync.yaml index 01addf54d74b..047287fd8d7e 100644 --- a/.github/workflows/generated_files_sync.yaml +++ b/.github/workflows/generated_files_sync.yaml @@ -102,7 +102,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: checking any files matching gitignore - shell: bash + shell: /usr/bin/bash --noprofile --norc -o pipefail {0} run: | find . -type f -name '*.java' -not -path './.git/*' \ |git check-ignore --no-index --verbose --stdin From 289e525f3a64f0a812b27543bb25f8240e187980 Mon Sep 17 00:00:00 2001 From: Tomo Suzuki Date: Mon, 10 Oct 2022 09:28:45 -0400 Subject: [PATCH 4/4] added comment --- .github/workflows/generated_files_sync.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/generated_files_sync.yaml b/.github/workflows/generated_files_sync.yaml index 047287fd8d7e..034ab008b4ae 100644 --- a/.github/workflows/generated_files_sync.yaml +++ b/.github/workflows/generated_files_sync.yaml @@ -102,10 +102,15 @@ jobs: steps: - uses: actions/checkout@v3 - name: checking any files matching gitignore + # By default, GitHub Actions's bash has '-e' option to fail immediately + # upon non-zero exit code. Not using it here to catch the exit code 1. shell: /usr/bin/bash --noprofile --norc -o pipefail {0} run: | find . -type f -name '*.java' -not -path './.git/*' \ |git check-ignore --no-index --verbose --stdin + # https://git-scm.com/docs/git-check-ignore returns 1 when there's no + # matching files with the gitignore file. + # "--no-index" is needed to check against tracked files. if [ "$?" == 1 ]; then echo "No matching files. Good." exit 0