name: Run composition file with a custom git reference on: workflow_call: inputs: composition_file: description: the workflow we're going to run required: true type: string custom_git_reference: description: the git commit or branch we're going to use for the custom target required: false type: string custom_git_target: description: the custom git fork url we're going to use for the custom target (github.com/some-fork/rust-libp2p) required: false type: string custom_interop_target: description: in the case of cross-implementation testing, the implementation target (go | rust | ...) required: false type: string testground_endpoint: required: false type: string test_repository: required: false type: string test_ref: required: false type: string jobs: run_test: name: Run a test with different versions runs-on: ubuntu-latest env: TEST_PLAN_REPO: ${{ inputs.test_repository || 'libp2p/test-plans' }} TEST_PLAN_BRANCH: ${{ inputs.test_ref || 'master' }} TESTGROUND_ENDPOINT: ${{ inputs.testground_endpoint }} COMPOSITION_FILE: ${{ inputs.composition_file }} defaults: run: shell: bash steps: - name: Checkout sources uses: actions/checkout@v2 with: path: test-plans repository: ${{ env.TEST_PLAN_REPO }} ref: ${{ env.TEST_PLAN_BRANCH }} - name: setup testground uses: ./test-plans/.github/actions/setup-testground - name: Import the plan working-directory: ./test-plans run: | testground plan import --from ./ --name libp2p - name: Resolve the git references if: ${{ inputs.custom_git_reference && inputs.custom_git_target }} id: resolve_reference working-directory: ./test-plans run: | git fetch https://${{ inputs.custom_git_target }} ${{ inputs.custom_git_reference }} SHA=`git log FETCH_HEAD -n 1 --pretty=format:"%H"` echo "::set-output name=custom_git_sha::${SHA}" - name: Build the composition file working-directory: ./test-plans timeout-minutes: 40 run: | for i in 1 2 3; do echo "=== Attempt $i ===" testground build composition \ -f "${COMPOSITION_FILE}" \ --write-artifacts \ --wait && exit 0; sleep 10 done exit 1 env: GitReference: ${{ steps.resolve_reference.outputs.custom_git_sha || inputs.custom_git_reference }} GitTarget: ${{ inputs.custom_git_target }} InteropTarget: ${{ inputs.custom_interop_target }} - name: Run the composition file working-directory: ./test-plans timeout-minutes: 6 run: | testground run composition \ -f "${COMPOSITION_FILE}" \ --metadata-repo "${GITHUB_REPOSITORY}" \ --metadata-branch "${GITHUB_REF#refs/heads/}" \ --metadata-commit "${GITHUB_SHA}" \ --collect-file ./result.tgz \ --collect --wait env: GitReference: ${{ steps.resolve_reference.outputs.custom_git_sha || inputs.custom_git_reference }} GitTarget: ${{ inputs.custom_git_target }} InteropTarget: ${{ inputs.custom_interop_target }} - uses: actions/upload-artifact@v3 if: ${{ failure() }} with: name: testground-output path: | ~/testground/ ~/test-plans/result.tgz ${{env.COMPOSITION_FILE}} testground.* test-plans/*.out