Skip to content

Commit

Permalink
chore: fix false positive in checking generated servers (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielc authored Feb 6, 2024
1 parent 3308838 commit dc01c95
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 40 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/rust-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ jobs:
# Cache only the cargo registry
cache-targets: false
- uses: mozilla-actions/[email protected]
- name: git file permission config
run: git config --global --add safe.directory '*'
- name: Check fmt
run: make check-fmt
- name: Check clippy
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ gen-api-server: api/ceramic.yaml
# Checks api-server crate is up-to-date
.PHONY: check-api-server
check-api-server:
./ci-scripts/check_api_server.sh
./ci-scripts/check_generated_server.sh api-server ./ci-scripts/gen_api_server.sh

# Generates kubo-rpc-server crate from ceramic.yaml OpenAPI spec
.PHONY: gen-kubo-rpc-server
Expand All @@ -52,7 +52,7 @@ gen-kubo-rpc-server:
# Checks kubo-rpc-server crate is up-to-date
.PHONY: check-kubo-rpc-server
check-kubo-rpc-server:
./ci-scripts/check_kubo_rpc_server.sh
./ci-scripts/check_generated_server.sh kubo-rpc-server ./ci-scripts/gen_kubo_rpc_server.sh

.PHONY: release
release:
Expand Down
19 changes: 0 additions & 19 deletions ci-scripts/check_api_server.sh

This file was deleted.

29 changes: 29 additions & 0 deletions ci-scripts/check_generated_server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
# Script to check a generated server has not changed

server_dir=$1
server_gen_cmd=$2

DIR=$(dirname $0)
cd "$DIR/.."

# First generate
$server_gen_cmd > /dev/null

# Check if anything changed, the README contains a generation date, ignore that file.
status=$(git status --porcelain $server_dir)
if [ $? -ne 0 ]
then
echo "Failed to get git status"
exit 1
fi

changes=$(echo "$status" | grep -v README.md)
if [[ -n "$changes" ]]
then
echo "Found ${server_dir} changes:"
echo "$changes"
exit 1
fi
echo "Generated ${server_dir} is up-to-date"
exit 0
19 changes: 0 additions & 19 deletions ci-scripts/check_kubo_rpc_server.sh

This file was deleted.

2 changes: 2 additions & 0 deletions ci-scripts/gen_api_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# Script to generate api-server crate from OpenAPI definition.
# Requires augeas/augtool to be installed

set -e

DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd $DIR/..

Expand Down

0 comments on commit dc01c95

Please sign in to comment.