This is an automated email from the ASF dual-hosted git repository. ctubbsii pushed a commit to branch 2.1 in repository https://gitbox.apache.org/repos/asf/accumulo.git
commit b59dfa9564da59a3e7dff79dd0220aae45af25bf Author: Christopher Tubbs <[email protected]> AuthorDate: Fri Apr 28 10:40:08 2023 -0400 Add CI check to detect Thrift changes (#3362) Add a GitHub Actions check that re-generates the Thrift generated code, and compares the alterations to what's committed to the repo. The check will fail if Thrift generates something that isn't checked in. This ensures that we can ignore generated code changes when reviewing pull requests, because if the generated code contained anything unexpected, this check would make it obvious. This fixes #3095 --- .github/workflows/scripts.yaml | 16 ++++++++++++++++ contrib/ci/install-thrift.sh | 31 +++++++++++++++++++++++++++++++ contrib/ci/run-thrift.sh | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) diff --git a/.github/workflows/scripts.yaml b/.github/workflows/scripts.yaml index 8409978d8e..2189d9c868 100644 --- a/.github/workflows/scripts.yaml +++ b/.github/workflows/scripts.yaml @@ -59,3 +59,19 @@ jobs: - name: Running shellcheck on all scripts run: contrib/ci/run-shellcheck.sh + thrift: + name: Thrift + timeout-minutes: 3 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Show the first log message + run: git log -n1 + - name: Update package repository + run: sudo apt-get update + - name: Install xmllint + run: sudo apt-get install libxml2-utils + - name: Install thrift + run: contrib/ci/install-thrift.sh + - name: Running thrift to check for changes + run: contrib/ci/run-thrift.sh diff --git a/contrib/ci/install-thrift.sh b/contrib/ci/install-thrift.sh new file mode 100755 index 0000000000..a46e7c694f --- /dev/null +++ b/contrib/ci/install-thrift.sh @@ -0,0 +1,31 @@ +#! /usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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 +# +# https://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. +# + +# Download the correct version of Thrift to do CI checks + +set -e + +thriftdefault="0.16.0" +rootDir=$(git rev-parse --show-toplevel 2>/dev/null) || ver=$thriftdefault +ver=$({ xmllint --shell "$rootDir/pom.xml" <<<'xpath /*[local-name()="project"]/*[local-name()="properties"]/*[local-name()="thrift.version"]/text()' | grep content= | cut -f2 -d=; } 2>/dev/null || echo "$thriftdefault") +ver=${ver%%-*} + +sudo wget "https://dist.apache.org/repos/dist/dev/accumulo/devtools/thrift-$ver/thrift" -O /usr/local/bin/thrift && + sudo chmod +x /usr/local/bin/thrift diff --git a/contrib/ci/run-thrift.sh b/contrib/ci/run-thrift.sh new file mode 100755 index 0000000000..95694191f8 --- /dev/null +++ b/contrib/ci/run-thrift.sh @@ -0,0 +1,35 @@ +#! /usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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 +# +# https://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. +# + +# Check that the generated thrift code hasn't changed from +# what is currently checked in to the repository + +set -e + +echo 'Checking if thrift modified any files...' +(cd core && src/main/scripts/generate-thrift.sh) + +if [[ -n $(git status --porcelain --ignored=no) ]]; then + echo 'Thrift build changed files in worktree:' + git status --short --ignored=no + exit 1 +else + echo 'No changes detected.' +fi
