From ca26558ea274c3b0a3dbec10d2468a0ce7b4d9a0 Mon Sep 17 00:00:00 2001 From: Marko Justinek Date: Fri, 26 Apr 2024 15:26:02 +1000 Subject: [PATCH] ci: Pass github.workspace to reusable workflow --- .../workflows/{build_test.yml => branch.yml} | 5 +- .github/workflows/pr.yml | 48 +++++++++++++++++++ .github/workflows/test_macos14_arm64.yml | 11 +++-- Support/build_test | 11 +---- 4 files changed, 56 insertions(+), 19 deletions(-) rename .github/workflows/{build_test.yml => branch.yml} (97%) create mode 100644 .github/workflows/pr.yml diff --git a/.github/workflows/build_test.yml b/.github/workflows/branch.yml similarity index 97% rename from .github/workflows/build_test.yml rename to .github/workflows/branch.yml index 0a6dcd8..4b9563e 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/branch.yml @@ -1,12 +1,8 @@ name: "Build and Test" on: - pull_request: - branches: - - 'main' push: branches: - - 'main' - 'chore/**' - 'docs/**' - 'feat/**' @@ -58,6 +54,7 @@ jobs: binaries-path: ${{ needs.sharedInputs.outputs.binaries-path }} cache-key: ${{ needs.sharedInputs.outputs.cache-key }} cache-restore-key: ${{ needs.sharedInputs.outputs.cache-restore-key }} + submit-coverage-report: false testMacOS13: name: "🤖 Unit tests" diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..aad54c2 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,48 @@ +name: "Build and Test" + +on: + pull_request: + branches: + - main + +env: + RUST_TARGET_PATH: pact-reference/rust/target + BINARIES_PATH: Resources + CACHE_KEY: build-ffi-rust + CACHE_RESTORE_KEY: build-ffi-rust + +jobs: + sharedInputs: + name: "🔣 Shared envs" + runs-on: ubuntu-latest + outputs: + rust-target-path: ${{ env.RUST_TARGET_PATH }} + binaries-path: ${{ env.BINARIES_PATH }} + cache-key: ${{ env.CACHE_KEY }} + cache-restore-key: ${{ env.CACHE_RESTORE_KEY }} + + steps: + - run: echo "Just a hacky workaround for passing envs to jobs expecting them... ¯\_(ツ)_/¯" + + buildFFI: + name: "📦 Dependencies" + needs: [sharedInputs] + uses: ./.github/workflows/build_rust_binaries.yml + with: + rust-target-path: ${{ needs.sharedInputs.outputs.rust-target-path }} + binaries-path: ${{ needs.sharedInputs.outputs.binaries-path }} + cache-key: ${{ needs.sharedInputs.outputs.cache-key }} + cache-restore-key: ${{ needs.sharedInputs.outputs.cache-restore-key }} + + testMacOS14: + name: "🤖 Unit tests" + needs: [sharedInputs, buildFFI] + uses: ./.github/workflows/test_macos14_arm64.yml + secrets: + codecov_token: ${{ secrets.CODECOV_TOKEN }} + with: + rust-target-path: ${{ needs.sharedInputs.outputs.rust-target-path }} + binaries-path: ${{ needs.sharedInputs.outputs.binaries-path }} + cache-key: ${{ needs.sharedInputs.outputs.cache-key }} + cache-restore-key: ${{ needs.sharedInputs.outputs.cache-restore-key }} + submit-coverage-report: true diff --git a/.github/workflows/test_macos14_arm64.yml b/.github/workflows/test_macos14_arm64.yml index 63c71eb..1f35afe 100644 --- a/.github/workflows/test_macos14_arm64.yml +++ b/.github/workflows/test_macos14_arm64.yml @@ -15,6 +15,9 @@ on: cache-restore-key: required: true type: string + submit-coverage-report: + required: true + type: boolean secrets: codecov_token: required: true @@ -31,8 +34,10 @@ jobs: include: - scheme: "PactSwiftMockServer-iOS" destination: "platform=iOS Simulator,name=iPhone 15 Pro" + submit_code_coverage: true - scheme: "PactSwiftMockServer-macOS" destination: "arch=arm64" + submit_code_coverage: true env: SCHEME: ${{ matrix.scheme }} @@ -67,12 +72,8 @@ jobs: sh Support/build_test - name: "⬆️ Upload coverage reports" + if: ${{ matrix.submit_code_coverage && inputs.submit-coverage-report }} uses: codecov/codecov-action@v4 with: token: ${{ secrets.codecov_token }} - file: ".build/artifacts/${{ env.SCHEME }}-TestResultBundle.xcresult" - directory: ".build/artifacts" - fail_ci_if_error: true - flags: unittests - name: PactSwiftMockServer verbose: true diff --git a/Support/build_test b/Support/build_test index 0fb7b1d..fed7538 100755 --- a/Support/build_test +++ b/Support/build_test @@ -26,7 +26,6 @@ source "$SOURCE_DIR/utils.sh" # Properties SCHEME_TARGET_PAIRS=() -BUILD_PATH="$SOURCE_DIR/../.build" ############### # "private" @@ -78,14 +77,6 @@ fi for INDEX in "${SCHEME_TARGET_PAIRS[@]}"; do SCHEME="${INDEX%%:::*}" TARGET="${INDEX##*::}" - RESULT_BUNDLE_PATH="$BUILD_PATH/artifacts/$SCHEME-TestResultBundle.xcresult" - if [ $(folderExists "$RESULT_BUNDLE_PATH") == true ]; then - # Remove build data by previous runs - echo "ℹ️ Reoving results bundle from previous runs..." - executeCommand "rm -fr $RESULT_BUNDLE_PATH" - fi - - echo "🧪 Running tests" - executeCommand "xcodebuild -project \"PactSwiftMockServer.xcodeproj\" -scheme \"$SCHEME\" -destination \"$TARGET\" -enableCodeCoverage YES -derivedDataPath \"$BUILD_PATH/DerivedData\" -resultBundlePath \"$RESULT_BUNDLE_PATH\" GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES build test | xcbeautify" + executeCommand "xcodebuild -project \"PactSwiftMockServer.xcodeproj\" -scheme \"$SCHEME\" -destination \"$TARGET\" -enableCodeCoverage YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES build test | xcbeautify" done