From baf7a4904a838bd99f3a687f6199ef3ef44527f0 Mon Sep 17 00:00:00 2001 From: Filip Pospisil Date: Thu, 15 Feb 2024 10:07:11 +0100 Subject: [PATCH] Allow to link utils package during Main build of Camel tooling projects --- .github/workflows/main.yaml | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 76a65820b..2e8dd6489 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -12,6 +12,41 @@ concurrency: cancel-in-progress: true jobs: + init: + if: always() + runs-on: ubuntu-latest + name: Utils fork check + env: + USER: "${{ github.actor }}" + BRANCH: "${{ github.head_ref }}" + TOKEN: "${{ secrets.GITHUB_TOKEN }}" + outputs: + branch_exists: ${{ steps.checkBranch.outputs.exists }} + + steps: + - name: Check for branch in vscode-uitests-tooling + id: checkBranch + run: | + REPO_URL="https://api.github.com/repos/$USER/vscode-uitests-tooling/branches" + RESPONSE=$(curl -s -H "Authorization: Bearer $TOKEN" "$REPO_URL") + + if ([ $? -ne 0 ]); then + echo "exists=false" >> $GITHUB_OUTPUT + fi + + if echo "$RESPONSE" | jq '.message' &> /dev/null; then + if [[ $(echo "$RESPONSE" | jq -r '.message') == "Not Found" ]]; then + echo "exists=false" >> $GITHUB_OUTPUT + fi + else + BRANCH_EXISTS=$(echo "$RESPONSE" | jq -r '.[] | select(.name=="'"$BRANCH"'") | .name') + if [ "$BRANCH_EXISTS" == "$BRANCH" ]; then + echo "exists=true" >> $GITHUB_OUTPUT + else + echo "exists=false" >> $GITHUB_OUTPUT + fi + fi + main: strategy: matrix: @@ -24,13 +59,21 @@ jobs: CODE_VERSION: ${{ matrix.version }} CODE_TYPE: ${{ matrix.type }} TEST_RESOURCES: test-resources + USER: "${{ github.actor }}" + BRANCH: "${{ github.head_ref }}" runs-on: ${{ matrix.os }} + needs: [ init ] steps: - name: Checkout Repository uses: actions/checkout@v4 with: fetch-depth: 0 + + - name: Clone utils repo + if: ${{ needs.init.outputs.branch_exists == 'true' }} + run: | + git clone -b ${{ env.BRANCH }} https://github.com/${{ env.USER }}/vscode-uitests-tooling.git ../vscode-uitests-tooling - name: Set up JDK 17 uses: actions/setup-java@v4 @@ -80,6 +123,12 @@ jobs: if: matrix.os != 'ubuntu-latest' run: npm test + - name: Link utils to camel-lsp-client-vscode + if: ${{ needs.init.outputs.branch_exists == 'true' }} + run: | + npm run dev --prefix ../vscode-uitests-tooling + npm link ../vscode-uitests-tooling + - name: ui test (ubuntu) id: uiTest_Ubuntu if: matrix.os == 'ubuntu-latest'