Skip to content

Commit

Permalink
testing: streamline workflows for readability, remove realpath (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
grayside authored Jan 31, 2023
1 parent ef63a63 commit 2cd193f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ jobs:
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
defaults:
run:
working-directory: library # sync with env.LIBRARY_CHECKOUT_PATH
env:
# Library & Data Source repos using side-by-side checkout.
LIBRARY_CHECKOUT_PATH: library # sync with defaults.run.working-directory
Expand All @@ -58,30 +55,32 @@ jobs:
path: ${{ env.DATA_SOURCE_CHECKOUT_PATH }}

- name: Set Environment
run: echo "GENERATE_DATA_SOURCE=$(realpath ../protos-source-repo)" >> $GITHUB_ENV
# Validation Test execution requires absolute path to testdata.
run: echo "GENERATE_DATA_SOURCE=${PWD}/${DATA_SOURCE_CHECKOUT_PATH}" | tee -a $GITHUB_ENV

- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x

- name: Install the generator
run: |
bash tools/setup-generator.sh
run: bash tools/setup-generator.sh
working-directory: ${{ env.LIBRARY_CHECKOUT_PATH }}

- name: Run the generator
run: |
bash ./generate-code.sh
run: bash ./generate-code.sh
working-directory: ${{ env.LIBRARY_CHECKOUT_PATH }}
env:
GENERATE_PROTOC_PATH: tmp/protobuf/bin/protoc
GOFLAGS: "-v"

# This step identifies the github revision of the data source repository.
# This is used to create a detailed Pull Request description.
- name: Source Version
id: source-version
run: |
rev=$(git rev-parse --short HEAD)
echo "revision=${rev}" >> $GITHUB_OUTPUT
echo "revision=${rev}" | tee -a $GITHUB_OUTPUT
working-directory: ${{ env.DATA_SOURCE_CHECKOUT_PATH }}

- name: Create a pull request with updates
Expand Down
15 changes: 7 additions & 8 deletions .github/workflows/test-generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ jobs:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
working-directory: library # sync with env.LIBRARY_CHECKOUT_PATH
env:
# Library & Data Source repos using side-by-side checkout.
LIBRARY_CHECKOUT_PATH: library # sync with defaults.run.working-directory
Expand All @@ -60,19 +57,21 @@ jobs:
path: ${{ env.DATA_SOURCE_CHECKOUT_PATH }}

- name: Set Environment
run: echo "GENERATE_DATA_SOURCE=$(realpath ../protos-source-repo)" >> $GITHUB_ENV
# Validation Test execution requires absolute path to testdata.
run: echo "GENERATE_DATA_SOURCE=${PWD}/${DATA_SOURCE_CHECKOUT_PATH}" | tee -a $GITHUB_ENV

- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x

- name: Install the generator
run: |
bash tools/setup-generator.sh
run: bash tools/setup-generator.sh
working-directory: ${{ env.LIBRARY_CHECKOUT_PATH }}

- name: Run the generator
run: |
bash ./generate-code.sh
run: bash ./generate-code.sh
working-directory: ${{ env.LIBRARY_CHECKOUT_PATH }}
env:
GENERATE_PROTOC_PATH: tmp/protobuf/bin/protoc
GOFLAGS: "-v"
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Generate the library using protobuf-based tooling.
git clone https://github.com/googleapis/google-cloudevents-go
cd google-cloudevents-go
sh ./tools/setup-generator.sh
export GENERATE_DATA_SOURCE=$(realpath tmp/google-cloudevents)
export GENERATE_DATA_SOURCE="${PWD}/tmp/google-cloudevents"
export GENERATE_PROTOC_PATH=tmp/protobuf/bin/protoc
sh ./generate-code.sh
```
Expand Down
2 changes: 1 addition & 1 deletion tools/setup-generator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ echo
echo "Configure environment for generate_code.sh:"
echo "- Usage: Configure the path to protobuf tools ('export GENERATE_PROTOC_PATH=$PROTOC')"
if [[ -z "${GENERATE_DATA_SOURCE}" ]]; then
echo "- Usage: Configure the path to proto definitions ('export GENERATE_DATA_SOURCE=\$(realpath ${dest})')"
echo "- Usage: Configure the path to proto definitions ('export GENERATE_DATA_SOURCE=\"\$PWD/${dest}\")"
fi

echo
Expand Down

0 comments on commit 2cd193f

Please sign in to comment.