diff --git a/.github/workflows/build-and-run-tests.yml b/.github/workflows/build-and-run-tests.yml index d3e8e68ba4..28636e1600 100644 --- a/.github/workflows/build-and-run-tests.yml +++ b/.github/workflows/build-and-run-tests.yml @@ -18,9 +18,17 @@ jobs: uses: ./.github/workflows/build-and-run-tests-from-branch.yml secrets: inherit - publish_plugin_and_cli: + publish_plugin: needs: build-and-run-tests - uses: ./.github/workflows/publish-plugin-and-cli-from-branch.yml + uses: ./.github/workflows/publish-plugin-from-branch.yml + with: + # upload artifacts on push action to main only + upload-artifact: ${{ github.event_name == 'push' }} + secrets: inherit + + publish_cli: + needs: build-and-run-tests + uses: ./.github/workflows/publish-cli-from-branch.yml with: # upload artifacts on push action to main only upload-artifact: ${{ github.event_name == 'push' }} diff --git a/.github/workflows/publish-cli-from-branch.yml b/.github/workflows/publish-cli-from-branch.yml new file mode 100644 index 0000000000..66190711a1 --- /dev/null +++ b/.github/workflows/publish-cli-from-branch.yml @@ -0,0 +1,99 @@ +name: "[M] CLI: publish as archive" + +on: + workflow_call: + inputs: + upload-artifact: + type: string + description: "Upload artifacts or not" + required: false + default: false + commit_sha: + required: false + type: string + description: "(optional) Commit SHA" + custom_version: + type: string + description: "Custom version" + required: false + default: "" + + workflow_dispatch: + inputs: + upload-artifact: + type: choice + description: "Upload artifacts or not" + required: false + default: true + options: + - true + - false + commit_sha: + required: false + type: string + description: "(optional) Commit SHA" + custom_version: + type: string + description: "Custom version" + required: false + default: "" + +jobs: + publish_cli: + strategy: + fail-fast: false # force to execute all jobs even though some of them have failed + matrix: + configuration: + - plugin_type: IC + extra_options: "-PideType=IC" + lang: java + dir: utbot-cli + - plugin_type: IC + extra_options: "-PideType=IC" + lang: python + dir: utbot-cli-python + - plugin_type: IU + extra_options: "-PideType=IU" + lang: go + dir: utbot-cli-go + - plugin_type: IU + extra_options: "-PideType=IU" + lang: js + dir: utbot-cli-js + runs-on: ubuntu-20.04 + container: unittestbot/java-env:java17-zulu-jdk-gradle7.6.1-kotlinc1.8.0 + steps: + - uses: actions/checkout@v3 + - name: Check out ${{ github.event.inputs.commit_sha }} commit + if: github.event.inputs.commit_sha != '' + run: | + git config --global --add safe.directory ${GITHUB_WORKSPACE} + git fetch + git checkout ${{ github.event.inputs.commit_sha }} + + # "You can make an environment variable available to any subsequent steps in a workflow job by + # defining or updating the environment variable and writing this to the GITHUB_ENV environment file." + - name: Setup custom version + if: ${{ github.event.inputs.custom_version != '' }} + run: | + echo "VERSION=${{ github.event.inputs.custom_version }}" >> $GITHUB_ENV + - name: Setup version + if: ${{ github.event.inputs.custom_version == '' }} + shell: bash + run: | + echo "VERSION=${GITHUB_REF_NAME:0:4}-$(date +%Y).$(date +%-m).${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV + + - name: Print environment variables + run: printenv + + - name: Build UTBot CLI + run: | + cd "${{ matrix.configuration.dir }}" + gradle clean build --no-daemon --build-cache --no-parallel ${{ matrix.configuration.extra_options }} -Dorg.gradle.jvmargs=-Xmx2g -Dkotlin.daemon.jvm.options=-Xmx4g -PsemVer=${{ env.VERSION }} + + - name: Archive UTBot CLI + if: ${{ inputs.upload-artifact == 'true' }} + uses: actions/upload-artifact@v3 + with: + name: utbot-cli-${{ matrix.configuration.lang }}-${{ env.VERSION }} + path: ${{ matrix.configuration.dir }}/build/libs/${{ matrix.configuration.dir }}-${{ env.VERSION }}.jar diff --git a/.github/workflows/publish-plugin-and-cli-from-branch.yml b/.github/workflows/publish-plugin-from-branch.yml similarity index 50% rename from .github/workflows/publish-plugin-and-cli-from-branch.yml rename to .github/workflows/publish-plugin-from-branch.yml index 3c76174e43..a6459307cf 100644 --- a/.github/workflows/publish-plugin-and-cli-from-branch.yml +++ b/.github/workflows/publish-plugin-from-branch.yml @@ -1,56 +1,56 @@ -name: "[M] Plugin and CLI: publish as archives" +name: "[M] Plugin: publish as archive" -on: +on: workflow_call: inputs: - upload-artifact: - type: string - description: "Upload artifacts or not" - required: false - default: false - commit_sha: - required: false - type: string - description: "(optional) Commit SHA" - custom_version: - type: string - description: "Custom version" - required: false - default: "" + upload-artifact: + type: string + description: "Upload artifacts or not" + required: false + default: false + commit_sha: + required: false + type: string + description: "(optional) Commit SHA" + custom_version: + type: string + description: "Custom version" + required: false + default: "" workflow_dispatch: inputs: - upload-artifact: - type: choice - description: "Upload artifacts or not" - required: false - default: true - options: + upload-artifact: + type: choice + description: "Upload artifacts or not" + required: false + default: true + options: - true - false - commit_sha: - required: false - type: string - description: "(optional) Commit SHA" - custom_version: - type: string - description: "Custom version" - required: false - default: "" + commit_sha: + required: false + type: string + description: "(optional) Commit SHA" + custom_version: + type: string + description: "Custom version" + required: false + default: "" jobs: - publish_plugin_and_cli: - strategy: - fail-fast: false # force to execute all jobs even though some of them have failed - matrix: - configuration: - - plugin_type: IC - extra_options: "-PideType=IC" - - plugin_type: IU - extra_options: "-PideType=IU" - runs-on: ubuntu-20.04 - container: unittestbot/java-env:java17-zulu-jdk-gradle7.6.1-kotlinc1.8.0 - steps: + publish_plugin_and_cli: + strategy: + fail-fast: false # force to execute all jobs even though some of them have failed + matrix: + configuration: + - plugin_type: IC + extra_options: "-PideType=IC" + - plugin_type: IU + extra_options: "-PideType=IU" + runs-on: ubuntu-20.04 + container: unittestbot/java-env:java17-zulu-jdk-gradle7.6.1-kotlinc1.8.0 + steps: - uses: actions/checkout@v3 - name: Check out ${{ github.event.inputs.commit_sha }} commit if: github.event.inputs.commit_sha != '' @@ -87,15 +87,3 @@ jobs: with: name: utbot-intellij-${{ matrix.configuration.plugin_type }}-${{ env.VERSION }} path: utbot-intellij/build/distributions/* - - - name: Build UTBot CLI - run: | - cd utbot-cli - gradle clean build --no-daemon --build-cache --no-parallel -Dorg.gradle.jvmargs=-Xmx2g -Dkotlin.daemon.jvm.options=-Xmx4g -PsemVer=${{ env.VERSION }} - - - name: Archive UTBot CLI - if: ${{ inputs.upload-artifact == 'true' && matrix.configuration.plugin_type == 'IC' }} - uses: actions/upload-artifact@v3 - with: - name: utbot-cli-${{ env.VERSION }} - path: utbot-cli/build/libs/utbot-cli-${{ env.VERSION }}.jar