Skip to content

ci: fix github release permissions and tag triggers #57

ci: fix github release permissions and tag triggers

ci: fix github release permissions and tag triggers #57

Workflow file for this run

name: CI
on:
push:
branches: ["master", "main"]
tags: ["*"]
pull_request:
branches: ["master", "main"]
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y cmake build-essential python3 curl git python3-pip
- name: Install pre-commit
run: pip3 install --break-system-packages pre-commit || pip3 install pre-commit
- name: Check code formatting and lint
run: pre-commit run clang-format --all-files && pre-commit run cpplint --all-files
- name: Configure CMake
run: cmake -B build -S . -DCMAKE_BUILD_TYPE=Debug -DCOVERAGE=ON
- name: Build
run: cmake --build build -j4
- name: Test
run: cd build && ctest --output-on-failure
- name: Pre-commit checks (Coverage)
run: |
python3 tools/test_coverage.py
python3 tools/doc_coverage.py src
- name: Download test spec files
run: |
curl -sL https://raw.githubusercontent.com/SamuelMarks/cdd-openapi-test-harness/master/petstore.json -o ../petstore.json
curl -sL https://raw.githubusercontent.com/SamuelMarks/cdd-openapi-test-harness/master/petstore_oas3.json -o ../petstore_oas3.json
- name: Setup Swagger 2.0 Petstore
run: |
docker run -d -p 8080:8080 -e SWAGGER_HOST="http://127.0.0.1:8080" -e SWAGGER_BASE_PATH="/v2" --name petstore_server_v2 swaggerapi/petstore
echo "Waiting for Swagger 2.0 Petstore to start..."
for i in {1..30}; do
if curl -s -f -o /dev/null http://127.0.0.1:8080/v2/swagger.json; then
echo "Swagger 2.0 Petstore is up!"
break
fi
sleep 5
done
- name: Test Swagger 2.0 SDK Generation and Execution
run: |
rm -rf ../cdd-cpp-client-v2
./build/cdd-cpp from_openapi to_sdk -i ../petstore.json -o ../cdd-cpp-client-v2 --tests
cd ../cdd-cpp-client-v2
cmake . -DFETCHCONTENT_UPDATES_DISCONNECTED=ON
cmake --build .
PETSTORE_URL="http://127.0.0.1:8080/v2" ./tests/client_test
- name: Teardown Swagger 2.0 Petstore
if: always()
run: docker rm -f petstore_server_v2 || true
- name: Setup OpenAPI 3.2.0 Petstore
run: |
docker run -d -p 8080:8080 -e SWAGGER_HOST="http://127.0.0.1:8080" -e SWAGGER_BASE_PATH="/api/v3" --name petstore_server_v3 swaggerapi/petstore
echo "Waiting for OpenAPI 3.2.0 Petstore to start..."
for i in {1..30}; do
if curl -s -f -o /dev/null http://127.0.0.1:8080/api/v3/swagger.json; then
echo "OpenAPI 3.2.0 Petstore is up!"
break
fi
sleep 5
done
- name: Test OpenAPI 3.2.0 SDK Generation and Execution
run: |
rm -rf ../cdd-cpp-client-v3
./build/cdd-cpp from_openapi to_sdk -i ../petstore_oas3.json -o ../cdd-cpp-client-v3 --tests
cd ../cdd-cpp-client-v3
cmake . -DFETCHCONTENT_UPDATES_DISCONNECTED=ON
cmake --build .
PETSTORE_URL="http://127.0.0.1:8080/api/v3" ./tests/client_test
- name: Teardown OpenAPI 3.2.0 Petstore
if: always()
run: docker rm -f petstore_server_v3 || true
- name: Build WASM
run: python3 -c "import sys; sys.path.append('scripts'); import run_pre_commit_checks as r; r.build_wasm()"
- name: Release Build
if: success() && startsWith(github.ref, 'refs/tags/')
run: |
cmake -B build_release -S . -DCMAKE_BUILD_TYPE=Release
cmake --build build_release -j4
mkdir -p custom_bin
cp build_release/cdd-cpp custom_bin/
cp bin/cdd-cpp.wasm custom_bin/
- name: Upload Binary Release
if: success() && startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
custom_bin/cdd-cpp
custom_bin/cdd-cpp.wasm