diff --git a/.github/workflows/centos7-tests.yaml b/.github/workflows/docker-tests.yml similarity index 56% rename from .github/workflows/centos7-tests.yaml rename to .github/workflows/docker-tests.yml index 5d045646..78d9615e 100644 --- a/.github/workflows/centos7-tests.yaml +++ b/.github/workflows/docker-tests.yml @@ -1,4 +1,4 @@ -name: CentOS7-tests@TF +name: container-tests at Testing Farm on: issue_comment: @@ -7,15 +7,40 @@ on: jobs: build: # This job only runs for '[test]' pull request comments by owner, member - name: Schedule test on Testing Farm service for CentOS7 + name: Container tests on Testing Farm service runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: + include: + - tmt_plan: "fedora" + os_test: "fedora" + context: "Fedora" + compose: "CentOS-7" + tmt_url: "http://artifacts.dev.testing-farm.io/" + tmt_repo: "https://github.com/sclorg/sclorg-testing-farm" + - tmt_plan: "centos7" + os_test: "centos7" + context: "CentOS7" + compose: "CentOS-7" + tmt_url: "http://artifacts.dev.testing-farm.io/" + tmt_repo: "https://github.com/sclorg/sclorg-testing-farm" + - tmt_plan: "rhel7-docker" + os_test: "rhel7" + context: "RHEL7" + compose: "RHEL-7.9-Released" + tmt_url: "http://artifacts.osci.redhat.com/testing-farm/" + tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans" + - tmt_plan: "rhel8-docker" + os_test: "rhel8" + context: "RHEL8" + compose: "RHEL-8.3.1-Released" + tmt_url: "http://artifacts.osci.redhat.com/testing-farm/" + tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans" if: | github.event.issue.pull_request && (contains(github.event.comment.body, '[test]') || contains(github.event.comment.body, '[test-all]')) && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association) - outputs: - REQ_ID: ${{steps.sched_test.outputs.REQ_ID}} - SHA: ${{steps.sha.outputs.SHA}} steps: - name: Get pull request number id: pr_nr @@ -28,10 +53,9 @@ jobs: with: ref: "refs/pull/${{ steps.pr_nr.outputs.PR_NR }}/head" - - name: Get sha - id: sha + - name: SHA value + id: sha_value run: | - # Store SHA into outputs echo "::set-output name=SHA::$(git rev-parse HEAD)" - name: Create status check to pending @@ -39,71 +63,62 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - # Create a JSON file for Testing Farm in order to schedule a CI testing job + # Create a JSON data structure for GitHub API to display the test status in the PR cat << EOF > pending.json { - "sha": "${{steps.sha.outputs.SHA}}", + "sha": "${{ steps.sha_value.outputs.SHA }}", "state": "pending", - "context": "Testing Farm - CentOS7", - "target_url": "http://artifacts.dev.testing-farm.io/${{ steps.sched_test.outputs.req_id }}/pipeline.log" + "context": "Testing Farm - ${{ matrix.context }}", + "target_url": "${{ matrix.tmt_url }}" } EOF - echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}}" + echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ steps.sha_value.outputs.SHA }}" # GITHUB_TOKEN is used for updating pull request status. # It is provided by GitHub https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}} \ + https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ steps.sha_value.outputs.SHA }} \ --data @pending.json echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY" - - name: Schedule a test on Testing Farm forn CentOS7 + - name: Schedule a test on Testing Farm id: sched_test run: | # Update ubuntu-20.04 in order to install curl and jq - apt update && apt -y install curl jq + sudo apt update && sudo apt -y install curl jq + if [ "${{ matrix.tmt_plan }}" == "fedora" ] || [ "${{ matrix.tmt_plan }}" == "centos7" ]; then + api_key="${{ secrets.TF_PUBLIC_API_KEY }}" + branch_name="main" + else + api_key="${{ secrets.TF_INTERNAL_API_KEY }}" + branch_name="master" + fi cat << EOF > request.json { - "api_key": "${{ secrets.TF_PUBLIC_API_KEY }}", + "api_key": "$api_key", "test": {"fmf": { - "url": "https://github.com/sclorg/sclorg-testing-farm", - "ref": "main", - "name": "fedora" + "url": "${{ matrix.tmt_repo }}", + "ref": "$branch_name", + "name": "${{ matrix.tmt_plan }}" }}, "environments": [{ "arch": "x86_64", - "os": {"compose": "CentOS-7"}, + "os": {"compose": "${{ matrix.compose }}"}, "variables": { "REPO_URL": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY", "REPO_NAME": "$GITHUB_REPOSITORY", "PR_NUMBER": "${{ steps.pr_nr.outputs.PR_NR }}", - "OS": "centos7", + "OS": "${{ matrix.os_test }}", "TEST_NAME": "test" } }] } EOF curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json + cat response.json + # Store REQ_ID into outputs for later on usage - echo "::set-output name=REQ_ID::$(jq -r .id response.json)" - - running: - needs: build - name: Check running tests on Testing Farm service - runs-on: ubuntu-20.04 - outputs: - REQ_ID: ${{steps.req_sha.outputs.REQ_ID}} - SHA: ${{steps.req_sha.outputs.SHA}} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - name: Check if REQ_ID and SHA exists - id: req_sha - run: | - # Update ubuntu-20.04 in order to install curl and jq - # each job is separate machine - apt update && apt -y install curl jq - # Propagate REQ_ID and SHA into the finish section - echo "::set-output name=REQ_ID::${{needs.build.outputs.REQ_ID}}" - echo "::set-output name=SHA::${{needs.build.outputs.SHA}}" + req_id=$(jq -r .id response.json) + echo "REQ_ID=$req_id" >> $GITHUB_ENV - name: Switch to running state of Testing Farm request id: running @@ -111,23 +126,24 @@ jobs: # Create running.json file for query, whether job is finished or not. cat << EOF > running.json { - "sha": "${{needs.build.outputs.SHA}}", + "sha": "${{ steps.sha_value.outputs.SHA }}", "state": "pending", - "context": "Testing Farm - CentOS7", + "context": "Testing Farm - ${{ matrix.context }}", "description": "Build started", - "target_url": "http://artifacts.dev.testing-farm.io/${{ needs.build.outputs.REQ_ID }}/" + "target_url": "${{ matrix.tmt_url }}/${{ env.REQ_ID }}" } EOF # Update GitHub status description to 'Build started' - curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.build.outputs.SHA}} \ + curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ steps.sha_value.outputs.SHA }} \ --data @running.json - name: Check test is still running id: still_running run: | - CMD=${{ secrets.TF_ENDPOINT }}/requests/${{needs.build.outputs.REQ_ID}} + CMD=${{ secrets.TF_ENDPOINT }}/requests/${{ env.REQ_ID }} curl $CMD > job.json + cat job.json state=$(jq -r .state job.json) # Wait till job is not finished. As soon as state is complete or failure then go to the finish action while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do @@ -137,24 +153,10 @@ jobs: state=$(jq -r .state job.json) done - finish: - needs: running - name: Tests are finished - switching to proper state - runs-on: ubuntu-20.04 - steps: - - name: Check if REQ_ID exists - run: echo "${{ needs.running.outputs.REQ_ID }}" - - - name: Check if SHA exists - run: echo "${{ needs.running.outputs.SHA }}" - - name: Get final state of Testing Farm request id: final_state run: | - # Update ubuntu-20.04 in order to install curl and jq - # each job is separate machine - apt update && apt -y install curl jq - curl ${{ secrets.TF_ENDPOINT }}/requests/${{needs.running.outputs.REQ_ID}} > job.json + curl ${{ secrets.TF_ENDPOINT }}/requests/${{ env.REQ_ID }} > job.json cat job.json state=$(jq -r .state job.json) result=$(jq -r .result.overall job.json) @@ -179,15 +181,15 @@ jobs: run: | cat << EOF > final.json { - "sha": "${{needs.running.outputs.SHA}}", - "state": "${{steps.final_state.outputs.FINAL_STATE}}", - "context": "Testing Farm - CentOS7", - "description": "Build finished${{steps.final_state.outputs.INFRA_STATE}}", - "target_url": "http://artifacts.dev.testing-farm.io/${{ needs.running.outputs.REQ_ID }}/" + "sha": "${{ steps.sha_value.outputs.SHA }}", + "state": "${{ steps.final_state.outputs.FINAL_STATE }}", + "context": "Testing Farm - ${{ matrix.context }}", + "description": "Build finished${{ steps.final_state.outputs.INFRA_STATE }}", + "target_url": "${{ matrix.tmt_url }}/${{ env.REQ_ID }}" } EOF cat final.json # Switch Github status to proper state - curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.running.outputs.SHA}} \ + curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ steps.sha_value.outputs.SHA }} \ --data @final.json diff --git a/.github/workflows/fedora-tests.yaml b/.github/workflows/fedora-tests.yaml deleted file mode 100644 index 07e4f6c6..00000000 --- a/.github/workflows/fedora-tests.yaml +++ /dev/null @@ -1,193 +0,0 @@ -name: Fedora-tests@TF - -on: - issue_comment: - types: - - created -jobs: - build: - # This job only runs for '[test]' pull request comments by owner, member - name: Schedule test on Testing Farm service for Fedora - runs-on: ubuntu-20.04 - if: | - github.event.issue.pull_request - && (contains(github.event.comment.body, '[test]') || contains(github.event.comment.body, '[test-all]')) - && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association) - outputs: - REQ_ID: ${{steps.sched_test.outputs.REQ_ID}} - SHA: ${{steps.sha.outputs.SHA}} - steps: - - name: Get pull request number - id: pr_nr - run: | - PR_URL="${{ github.event.comment.issue_url }}" - echo "::set-output name=PR_NR::${PR_URL##*/}" - - - name: Checkout repo - uses: actions/checkout@v2 - with: - ref: "refs/pull/${{ steps.pr_nr.outputs.PR_NR }}/head" - - - name: Get sha - id: sha - run: | - # Store SHA into outputs - echo "::set-output name=SHA::$(git rev-parse HEAD)" - - - name: Create status check to pending - id: pending - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - # Create a JSON file for Testing Farm in order to schedule a CI testing job - cat << EOF > pending.json - { - "sha": "${{steps.sha.outputs.SHA}}", - "state": "pending", - "context": "Testing Farm - Fedora", - "target_url": "http://artifacts.dev.testing-farm.io/${{ steps.sched_test.outputs.req_id }}/pipeline.log" - } - EOF - echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}}" - # GITHUB_TOKEN is used for updating pull request status. - # It is provided by GitHub https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret - curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}} \ - --data @pending.json - echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY" - - - name: Schedule a test on Testing Farm forn Fedora - id: sched_test - run: | - # Update ubuntu-20.04 in order to install curl and jq - apt update && apt -y install curl jq - cat << EOF > request.json - { - "api_key": "${{ secrets.TF_PUBLIC_API_KEY }}", - "test": {"fmf": { - "url": "https://github.com/sclorg/sclorg-testing-farm", - "ref": "main", - "name": "fedora" - }}, - "environments": [{ - "arch": "x86_64", - "os": {"compose": "CentOS-7"}, - "variables": { - "REPO_URL": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY", - "REPO_NAME": "$GITHUB_REPOSITORY", - "PR_NUMBER": "${{ steps.pr_nr.outputs.PR_NR }}", - "OS": "fedora", - "TEST_NAME": "test" - } - }] - } - EOF - curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json - # Store REQ_ID into outputs for later on usage - echo "::set-output name=REQ_ID::$(jq -r .id response.json)" - - running: - needs: build - name: Check running tests on Testing Farm service - runs-on: ubuntu-20.04 - outputs: - REQ_ID: ${{steps.req_sha.outputs.REQ_ID}} - SHA: ${{steps.req_sha.outputs.SHA}} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - name: Check if REQ_ID and SHA exists - id: req_sha - run: | - # Update ubuntu-20.04 in order to install curl and jq - # each job is separate machine - apt update && apt -y install curl jq - # Propagate REQ_ID and SHA into the finish section - echo "::set-output name=REQ_ID::${{needs.build.outputs.REQ_ID}}" - echo "::set-output name=SHA::${{needs.build.outputs.SHA}}" - - - name: Switch to running state of Testing Farm request - id: running - run: | - # Create running.json file for query, whether job is finished or not. - cat << EOF > running.json - { - "sha": "${{needs.build.outputs.SHA}}", - "state": "pending", - "context": "Testing Farm - Fedora", - "description": "Build started", - "target_url": "http://artifacts.dev.testing-farm.io/${{ needs.build.outputs.REQ_ID }}/" - } - EOF - # Update GitHub status description to 'Build started' - curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.build.outputs.SHA}} \ - --data @running.json - - - name: Check test is still running - id: still_running - run: | - CMD=${{ secrets.TF_ENDPOINT }}/requests/${{needs.build.outputs.REQ_ID}} - curl $CMD > job.json - state=$(jq -r .state job.json) - # Wait till job is not finished. As soon as state is complete or failure then go to the finish action - while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do - # Wait 30s. We do not need to query Testing Farm each second - sleep 30 - curl $CMD > job.json - state=$(jq -r .state job.json) - done - - finish: - needs: running - name: Tests are finished - switching to proper state - runs-on: ubuntu-20.04 - steps: - - name: Check if REQ_ID exists - run: echo "${{ needs.running.outputs.REQ_ID }}" - - - name: Check if SHA exists - run: echo "${{ needs.running.outputs.SHA }}" - - - name: Get final state of Testing Farm request - id: final_state - run: | - # Update ubuntu-20.04 in order to install curl and jq - # each job is separate machine - apt update && apt -y install curl jq - curl ${{ secrets.TF_ENDPOINT }}/requests/${{needs.running.outputs.REQ_ID}} > job.json - cat job.json - state=$(jq -r .state job.json) - result=$(jq -r .result.overall job.json) - new_state="success" - infra_error=" " - echo "State is $state and result is: $result" - if [ "$state" == "complete" ]; then - if [ "$result" != "passed" ]; then - new_state="failure" - fi - else - # Mark job in case of infrastructure issues. Report to Testing Farm team - infra_error=" - Infra problems" - new_state="failure" - fi - echo "New State is: $new_state" - echo "Infra state is: $infra_error" - echo "::set-output name=FINAL_STATE::$new_state" - echo "::set-output name=INFRA_STATE::$infra_error" - - - name: Switch to final state of Testing Farm request - run: | - cat << EOF > final.json - { - "sha": "${{needs.running.outputs.SHA}}", - "state": "${{steps.final_state.outputs.FINAL_STATE}}", - "context": "Testing Farm - Fedora", - "description": "Build finished${{steps.final_state.outputs.INFRA_STATE}}", - "target_url": "http://artifacts.dev.testing-farm.io/${{ needs.running.outputs.REQ_ID }}/" - } - EOF - cat final.json - # Switch Github status to proper state - curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.running.outputs.SHA}} \ - --data @final.json diff --git a/.github/workflows/centos7-openshift-tests.yaml b/.github/workflows/openshift-tests.yml similarity index 55% rename from .github/workflows/centos7-openshift-tests.yaml rename to .github/workflows/openshift-tests.yml index 02df7183..6cbe4c75 100644 --- a/.github/workflows/centos7-openshift-tests.yaml +++ b/.github/workflows/openshift-tests.yml @@ -1,4 +1,4 @@ -name: CentOS7-openshift-tests@TF +name: openshift-tests at Testing Farm on: issue_comment: @@ -7,15 +7,44 @@ on: jobs: build: # This job only runs for '[test]' pull request comments by owner, member - name: Schedule test on Testing Farm service for CentOS7 - OpenShift 3 + name: OpenShift tests on Testing Farm service runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: + include: + - tmt_plan: "centos7" + os_test: "centos7" + context: "CentOS7 - OpenShift 3" + compose: "CentOS-7" + tmt_url: "http://artifacts.dev.testing-farm.io/" + tmt_repo: "https://github.com/sclorg/sclorg-testing-farm" + test_name: "test-openshift" + - tmt_plan: "rhel7-openshift-3" + os_test: "rhel7" + context: "RHEL7 - OpenShift 3" + compose: "RHEL-7.9-Released" + tmt_url: "http://artifacts.osci.redhat.com/testing-farm/" + tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans" + test_name: "test-openshift" + - tmt_plan: "rhel7-openshift-4" + os_test: "rhel7" + context: "RHEL7 - OpenShift 4" + compose: "RHEL-7.9-Released" + tmt_url: "http://artifacts.osci.redhat.com/testing-farm/" + tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans" + test_name: "test-openshift-4" + - tmt_plan: "rhel8-openshift-4" + os_test: "rhel8" + context: "RHEL8 - OpenShift 4" + compose: "RHEL-8.3.1-Released" + tmt_url: "http://artifacts.osci.redhat.com/testing-farm/" + tmt_repo: "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans" + test_name: "test-openshift-4" if: | github.event.issue.pull_request && (contains(github.event.comment.body, '[test-openshift]') || contains(github.event.comment.body, '[test-all]')) && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association) - outputs: - REQ_ID: ${{steps.sched_test.outputs.REQ_ID}} - SHA: ${{steps.sha.outputs.SHA}} steps: - name: Get pull request number id: pr_nr @@ -28,10 +57,9 @@ jobs: with: ref: "refs/pull/${{ steps.pr_nr.outputs.PR_NR }}/head" - - name: Get sha - id: sha + - name: SHA value + id: sha_value run: | - # Store SHA into outputs echo "::set-output name=SHA::$(git rev-parse HEAD)" - name: Create status check to pending @@ -42,68 +70,59 @@ jobs: # Create a JSON file for Testing Farm in order to schedule a CI testing job cat << EOF > pending.json { - "sha": "${{steps.sha.outputs.SHA}}", + "sha": "${{ steps.sha_value.outputs.SHA }}", "state": "pending", - "context": "Testing Farm - CentOS7 - OpenShift 3", - "target_url": "http://artifacts.dev.testing-farm.io/${{ steps.sched_test.outputs.req_id }}/pipeline.log" + "context": "Testing Farm - ${{ matrix.context }}", + "target_url": "${{ matrix.tmt_url }}" } EOF - echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}}" + echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ steps.sha_value.outputs.SHA }}" # GITHUB_TOKEN is used for updating pull request status. # It is provided by GitHub https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}} \ + https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ steps.sha_value.outputs.SHA }} \ --data @pending.json echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY" - - name: Schedule a test on Testing Farm forn CentOS7 - OpenShift 3 + - name: Schedule a test on Testing Farm id: sched_test run: | # Update ubuntu-20.04 in order to install curl and jq - apt update && apt -y install curl jq + sudo apt update && sudo apt -y install curl jq + if [ "${{ matrix.tmt_plan }}" == "fedora" ] || [ "${{ matrix.tmt_plan }}" == "centos7" ]; then + api_key="${{ secrets.TF_PUBLIC_API_KEY }}" + branch_name="main" + else + api_key="${{ secrets.TF_INTERNAL_API_KEY }}" + branch_name="master" + fi cat << EOF > request.json { - "api_key": "${{ secrets.TF_PUBLIC_API_KEY }}", + "api_key": "$api_key", "test": {"fmf": { - "url": "https://github.com/sclorg/sclorg-testing-farm", - "ref": "main", - "name": "fedora" + "url": "${{ matrix.tmt_repo }}", + "ref": "$branch_name", + "name": "${{ matrix.tmt_plan }}" }}, "environments": [{ "arch": "x86_64", - "os": {"compose": "CentOS-7"}, + "os": {"compose": "${{ matrix.compose }}"}, "variables": { "REPO_URL": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY", "REPO_NAME": "$GITHUB_REPOSITORY", "PR_NUMBER": "${{ steps.pr_nr.outputs.PR_NR }}", - "OS": "centos7", - "TEST_NAME": "test-openshift" + "OS": "${{ matrix.os_test }}", + "TEST_NAME": "${{ matrix.test_name }}" } }] } EOF curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json - # Store REQ_ID into outputs for later on usage - echo "::set-output name=REQ_ID::$(jq -r .id response.json)" + cat response.json - running: - needs: build - name: Check running tests on Testing Farm service - runs-on: ubuntu-20.04 - outputs: - REQ_ID: ${{steps.req_sha.outputs.REQ_ID}} - SHA: ${{steps.req_sha.outputs.SHA}} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - name: Check if REQ_ID and SHA exists - id: req_sha - run: | - # Update ubuntu-20.04 in order to install curl and jq - # each job is separate machine - apt update && apt -y install curl jq - # Propagate REQ_ID and SHA into the finish section - echo "::set-output name=REQ_ID::${{needs.build.outputs.REQ_ID}}" - echo "::set-output name=SHA::${{needs.build.outputs.SHA}}" + # Store REQ_ID into outputs for later on usage + req_id=$(jq -r .id response.json) + echo "REQ_ID=$req_id" >> $GITHUB_ENV - name: Switch to running state of Testing Farm request id: running @@ -111,23 +130,24 @@ jobs: # Create running.json file for query, whether job is finished or not. cat << EOF > running.json { - "sha": "${{needs.build.outputs.SHA}}", + "sha": "${{ steps.sha_value.outputs.SHA }}", "state": "pending", - "context": "Testing Farm - CentOS7 - OpenShift 3", + "context": "Testing Farm - ${{ matrix.context }}", "description": "Build started", - "target_url": "http://artifacts.dev.testing-farm.io/${{ needs.build.outputs.REQ_ID }}/" + "target_url": "${{ matrix.tmt_url }}/${{ env.REQ_ID }}" } EOF # Update GitHub status description to 'Build started' - curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.build.outputs.SHA}} \ + curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ steps.sha_value.outputs.SHA }} \ --data @running.json - name: Check test is still running id: still_running run: | - CMD=${{ secrets.TF_ENDPOINT }}/requests/${{needs.build.outputs.REQ_ID}} + CMD=${{ secrets.TF_ENDPOINT }}/requests/${{ env.REQ_ID }} curl $CMD > job.json + cat job.json state=$(jq -r .state job.json) # Wait till job is not finished. As soon as state is complete or failure then go to the finish action while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do @@ -137,24 +157,10 @@ jobs: state=$(jq -r .state job.json) done - finish: - needs: running - name: Tests are finished - switching to proper state - runs-on: ubuntu-20.04 - steps: - - name: Check if REQ_ID exists - run: echo "${{ needs.running.outputs.REQ_ID }}" - - - name: Check if SHA exists - run: echo "${{ needs.running.outputs.SHA }}" - - name: Get final state of Testing Farm request id: final_state run: | - # Update ubuntu-20.04 in order to install curl and jq - # each job is separate machine - apt update && apt -y install curl jq - curl ${{ secrets.TF_ENDPOINT }}/requests/${{needs.running.outputs.REQ_ID}} > job.json + curl ${{ secrets.TF_ENDPOINT }}/requests/${{ env.REQ_ID }} > job.json cat job.json state=$(jq -r .state job.json) result=$(jq -r .result.overall job.json) @@ -179,15 +185,15 @@ jobs: run: | cat << EOF > final.json { - "sha": "${{needs.running.outputs.SHA}}", - "state": "${{steps.final_state.outputs.FINAL_STATE}}", - "context": "Testing Farm - CentOS7 - OpenShift 3", - "description": "Build finished${{steps.final_state.outputs.INFRA_STATE}}", - "target_url": "http://artifacts.dev.testing-farm.io/${{ needs.running.outputs.REQ_ID }}/" + "sha": "${{ steps.sha_value.outputs.SHA }}", + "state": "${{ steps.final_state.outputs.FINAL_STATE }}", + "context": "Testing Farm - ${{ matrix.context }}", + "description": "Build finished${{ steps.final_state.outputs.INFRA_STATE }}", + "target_url": "${{ matrix.tmt_url }}/${{ env.REQ_ID }}" } EOF cat final.json # Switch Github status to proper state - curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.running.outputs.SHA}} \ + curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{ steps.sha_value.outputs.SHA }} \ --data @final.json diff --git a/.github/workflows/rhel7-openshift-tests.yaml b/.github/workflows/rhel7-openshift-tests.yaml deleted file mode 100644 index 31b9c933..00000000 --- a/.github/workflows/rhel7-openshift-tests.yaml +++ /dev/null @@ -1,193 +0,0 @@ -name: RHEL7-openshift-tests@TF - -on: - issue_comment: - types: - - created -jobs: - build: - # This job only runs for '[test]' pull request comments by owner, member - name: Schedule test on Testing Farm service for RHEL7 - OpenShift 3 - runs-on: ubuntu-20.04 - if: | - github.event.issue.pull_request - && (contains(github.event.comment.body, '[test-openshift]') || contains(github.event.comment.body, '[test-all]')) - && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association) - outputs: - REQ_ID: ${{steps.sched_test.outputs.REQ_ID}} - SHA: ${{steps.sha.outputs.SHA}} - steps: - - name: Get pull request number - id: pr_nr - run: | - PR_URL="${{ github.event.comment.issue_url }}" - echo "::set-output name=PR_NR::${PR_URL##*/}" - - - name: Checkout repo - uses: actions/checkout@v2 - with: - ref: "refs/pull/${{ steps.pr_nr.outputs.PR_NR }}/head" - - - name: Get sha - id: sha - run: | - # Store SHA into outputs - echo "::set-output name=SHA::$(git rev-parse HEAD)" - - - name: Create status check to pending - id: pending - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - # Create a JSON file for Testing Farm in order to schedule a CI testing job - cat << EOF > pending.json - { - "sha": "${{steps.sha.outputs.SHA}}", - "state": "pending", - "context": "Testing Farm - RHEL7 - OpenShift 3", - "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ steps.sched_test.outputs.req_id }}" - } - EOF - echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}}" - # GITHUB_TOKEN is used for updating pull request status. - # It is provided by GitHub https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret - curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}} \ - --data @pending.json - echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY" - - - name: Schedule a test on Testing Farm forn RHEL7 - OpenShift 3 - id: sched_test - run: | - # Update ubuntu-20.04 in order to install curl and jq - apt update && apt -y install curl jq - cat << EOF > request.json - { - "api_key": "${{ secrets.TF_INTERNAL_API_KEY }}", - "test": {"fmf": { - "url": "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans", - "ref": "master", - "name": "rhel7-openshift-3" - }}, - "environments": [{ - "arch": "x86_64", - "os": {"compose": "RHEL-7.9-Released"}, - "variables": { - "REPO_URL": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY", - "REPO_NAME": "$GITHUB_REPOSITORY", - "PR_NUMBER": "${{ steps.pr_nr.outputs.PR_NR }}", - "OS": "rhel7", - "TEST_NAME": "test-openshift" - } - }] - } - EOF - curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json - # Store REQ_ID into outputs for later on usage - echo "::set-output name=REQ_ID::$(jq -r .id response.json)" - - running: - needs: build - name: Check running tests on Testing Farm service - runs-on: ubuntu-20.04 - outputs: - REQ_ID: ${{steps.req_sha.outputs.REQ_ID}} - SHA: ${{steps.req_sha.outputs.SHA}} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - name: Check if REQ_ID and SHA exists - id: req_sha - run: | - # Update ubuntu-20.04 in order to install curl and jq - # each job is separate machine - apt update && apt -y install curl jq - # Propagate REQ_ID and SHA into the finish section - echo "::set-output name=REQ_ID::${{needs.build.outputs.REQ_ID}}" - echo "::set-output name=SHA::${{needs.build.outputs.SHA}}" - - - name: Switch to running state of Testing Farm request - id: running - run: | - # Create running.json file for query, whether job is finished or not. - cat << EOF > running.json - { - "sha": "${{needs.build.outputs.SHA}}", - "state": "pending", - "context": "Testing Farm - RHEL7 - OpenShift 3", - "description": "Build started", - "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ needs.build.outputs.REQ_ID }}" - } - EOF - # Update GitHub status description to 'Build started' - curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.build.outputs.SHA}} \ - --data @running.json - - - name: Check test is still running - id: still_running - run: | - CMD=${{ secrets.TF_ENDPOINT }}/requests/${{needs.build.outputs.REQ_ID}} - curl $CMD > job.json - state=$(jq -r .state job.json) - # Wait till job is not finished. As soon as state is complete or failure then go to the finish action - while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do - # Wait 30s. We do not need to query Testing Farm each second - sleep 30 - curl $CMD > job.json - state=$(jq -r .state job.json) - done - - finish: - needs: running - name: Tests are finished - switching to proper state - runs-on: ubuntu-20.04 - steps: - - name: Check if REQ_ID exists - run: echo "${{ needs.running.outputs.REQ_ID }}" - - - name: Check if SHA exists - run: echo "${{ needs.running.outputs.SHA }}" - - - name: Get final state of Testing Farm request - id: final_state - run: | - # Update ubuntu-20.04 in order to install curl and jq - # each job is separate machine - apt update && apt -y install curl jq - curl ${{ secrets.TF_ENDPOINT }}/requests/${{needs.running.outputs.REQ_ID}} > job.json - cat job.json - state=$(jq -r .state job.json) - result=$(jq -r .result.overall job.json) - new_state="success" - infra_error=" " - echo "State is $state and result is: $result" - if [ "$state" == "complete" ]; then - if [ "$result" != "passed" ]; then - new_state="failure" - fi - else - # Mark job in case of infrastructure issues. Report to Testing Farm team - infra_error=" - Infra problems" - new_state="failure" - fi - echo "New State is: $new_state" - echo "Infra state is: $infra_error" - echo "::set-output name=FINAL_STATE::$new_state" - echo "::set-output name=INFRA_STATE::$infra_error" - - - name: Switch to final state of Testing Farm request - run: | - cat << EOF > final.json - { - "sha": "${{needs.running.outputs.SHA}}", - "state": "${{steps.final_state.outputs.FINAL_STATE}}", - "context": "Testing Farm - RHEL7 - OpenShift 3", - "description": "Build finished${{steps.final_state.outputs.INFRA_STATE}}", - "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ needs.running.outputs.REQ_ID }}" - } - EOF - cat final.json - # Switch Github status to proper state - curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.running.outputs.SHA}} \ - --data @final.json diff --git a/.github/workflows/rhel7-openshift4-tests.yaml b/.github/workflows/rhel7-openshift4-tests.yaml deleted file mode 100644 index c4c0170a..00000000 --- a/.github/workflows/rhel7-openshift4-tests.yaml +++ /dev/null @@ -1,193 +0,0 @@ -name: RHEL7-openshift4-tests@TF - -on: - issue_comment: - types: - - created -jobs: - build: - # This job only runs for '[test]' pull request comments by owner, member - name: Schedule test on Testing Farm service for RHEL7 - OpenShift 4 - runs-on: ubuntu-20.04 - if: | - github.event.issue.pull_request - && (contains(github.event.comment.body, '[test-openshift-4]') || contains(github.event.comment.body, '[test-all]')) - && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association) - outputs: - REQ_ID: ${{steps.sched_test.outputs.REQ_ID}} - SHA: ${{steps.sha.outputs.SHA}} - steps: - - name: Get pull request number - id: pr_nr - run: | - PR_URL="${{ github.event.comment.issue_url }}" - echo "::set-output name=PR_NR::${PR_URL##*/}" - - - name: Checkout repo - uses: actions/checkout@v2 - with: - ref: "refs/pull/${{ steps.pr_nr.outputs.PR_NR }}/head" - - - name: Get sha - id: sha - run: | - # Store SHA into outputs - echo "::set-output name=SHA::$(git rev-parse HEAD)" - - - name: Create status check to pending - id: pending - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - # Create a JSON file for Testing Farm in order to schedule a CI testing job - cat << EOF > pending.json - { - "sha": "${{steps.sha.outputs.SHA}}", - "state": "pending", - "context": "Testing Farm - RHEL7 - OpenShift 4", - "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ steps.sched_test.outputs.req_id }}" - } - EOF - echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}}" - # GITHUB_TOKEN is used for updating pull request status. - # It is provided by GitHub https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret - curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}} \ - --data @pending.json - echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY" - - - name: Schedule a test on Testing Farm forn RHEL7 - OpenShift 4 - id: sched_test - run: | - # Update ubuntu-20.04 in order to install curl and jq - apt update && apt -y install curl jq - cat << EOF > request.json - { - "api_key": "${{ secrets.TF_INTERNAL_API_KEY }}", - "test": {"fmf": { - "url": "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans", - "ref": "master", - "name": "rhel7-openshift-4" - }}, - "environments": [{ - "arch": "x86_64", - "os": {"compose": "RHEL-7.9-Released"}, - "variables": { - "REPO_URL": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY", - "REPO_NAME": "$GITHUB_REPOSITORY", - "PR_NUMBER": "${{ steps.pr_nr.outputs.PR_NR }}", - "OS": "rhel7", - "TEST_NAME": "test-openshift-4" - } - }] - } - EOF - curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json - # Store REQ_ID into outputs for later on usage - echo "::set-output name=REQ_ID::$(jq -r .id response.json)" - - running: - needs: build - name: Check running tests on Testing Farm service - runs-on: ubuntu-20.04 - outputs: - REQ_ID: ${{steps.req_sha.outputs.REQ_ID}} - SHA: ${{steps.req_sha.outputs.SHA}} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - name: Check if REQ_ID and SHA exists - id: req_sha - run: | - # Update ubuntu-20.04 in order to install curl and jq - # each job is separate machine - apt update && apt -y install curl jq - # Propagate REQ_ID and SHA into the finish section - echo "::set-output name=REQ_ID::${{needs.build.outputs.REQ_ID}}" - echo "::set-output name=SHA::${{needs.build.outputs.SHA}}" - - - name: Switch to running state of Testing Farm request - id: running - run: | - # Create running.json file for query, whether job is finished or not. - cat << EOF > running.json - { - "sha": "${{needs.build.outputs.SHA}}", - "state": "pending", - "context": "Testing Farm - RHEL7 - OpenShift 4", - "description": "Build started", - "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ needs.build.outputs.REQ_ID }}" - } - EOF - # Update GitHub status description to 'Build started' - curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.build.outputs.SHA}} \ - --data @running.json - - - name: Check test is still running - id: still_running - run: | - CMD=${{ secrets.TF_ENDPOINT }}/requests/${{needs.build.outputs.REQ_ID}} - curl $CMD > job.json - state=$(jq -r .state job.json) - # Wait till job is not finished. As soon as state is complete or failure then go to the finish action - while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do - # Wait 30s. We do not need to query Testing Farm each second - sleep 30 - curl $CMD > job.json - state=$(jq -r .state job.json) - done - - finish: - needs: running - name: Tests are finished - switching to proper state - runs-on: ubuntu-20.04 - steps: - - name: Check if REQ_ID exists - run: echo "${{ needs.running.outputs.REQ_ID }}" - - - name: Check if SHA exists - run: echo "${{ needs.running.outputs.SHA }}" - - - name: Get final state of Testing Farm request - id: final_state - run: | - # Update ubuntu-20.04 in order to install curl and jq - # each job is separate machine - apt update && apt -y install curl jq - curl ${{ secrets.TF_ENDPOINT }}/requests/${{needs.running.outputs.REQ_ID}} > job.json - cat job.json - state=$(jq -r .state job.json) - result=$(jq -r .result.overall job.json) - new_state="success" - infra_error=" " - echo "State is $state and result is: $result" - if [ "$state" == "complete" ]; then - if [ "$result" != "passed" ]; then - new_state="failure" - fi - else - # Mark job in case of infrastructure issues. Report to Testing Farm team - infra_error=" - Infra problems" - new_state="failure" - fi - echo "New State is: $new_state" - echo "Infra state is: $infra_error" - echo "::set-output name=FINAL_STATE::$new_state" - echo "::set-output name=INFRA_STATE::$infra_error" - - - name: Switch to final state of Testing Farm request - run: | - cat << EOF > final.json - { - "sha": "${{needs.running.outputs.SHA}}", - "state": "${{steps.final_state.outputs.FINAL_STATE}}", - "context": "Testing Farm - RHEL7 - OpenShift 4", - "description": "Build finished${{steps.final_state.outputs.INFRA_STATE}}", - "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ needs.running.outputs.REQ_ID }}" - } - EOF - cat final.json - # Switch Github status to proper state - curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.running.outputs.SHA}} \ - --data @final.json diff --git a/.github/workflows/rhel7-tests.yaml b/.github/workflows/rhel7-tests.yaml deleted file mode 100644 index 6210fc0c..00000000 --- a/.github/workflows/rhel7-tests.yaml +++ /dev/null @@ -1,193 +0,0 @@ -name: RHEL7-tests@TF - -on: - issue_comment: - types: - - created -jobs: - build: - # This job only runs for '[test]' pull request comments by owner, member - name: Schedule test on Testing Farm service for RHEL7 - runs-on: ubuntu-20.04 - if: | - github.event.issue.pull_request - && (contains(github.event.comment.body, '[test]') || contains(github.event.comment.body, '[test-all]')) - && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association) - outputs: - REQ_ID: ${{steps.sched_test.outputs.REQ_ID}} - SHA: ${{steps.sha.outputs.SHA}} - steps: - - name: Get pull request number - id: pr_nr - run: | - PR_URL="${{ github.event.comment.issue_url }}" - echo "::set-output name=PR_NR::${PR_URL##*/}" - - - name: Checkout repo - uses: actions/checkout@v2 - with: - ref: "refs/pull/${{ steps.pr_nr.outputs.PR_NR }}/head" - - - name: Get sha - id: sha - run: | - # Store SHA into outputs - echo "::set-output name=SHA::$(git rev-parse HEAD)" - - - name: Create status check to pending for RHEL7 - id: pending - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - # Create a JSON file for Testing Farm in order to schedule a CI testing job - cat << EOF > pending.json - { - "sha": "${{steps.sha.outputs.SHA}}", - "state": "pending", - "context": "Testing Farm - RHEL7", - "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ steps.sched_test.outputs.req_id }}/" - } - EOF - echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}}" - # GITHUB_TOKEN is used for updating pull request status. - # It is provided by GitHub https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret - curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}} \ - --data @pending.json - echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY" - - - name: Schedule a test on Testing Farm for RHEL7 - id: sched_test - run: | - # Update ubuntu-20.04 in order to install curl and jq - apt update && apt -y install curl jq - cat << EOF > request.json - { - "api_key": "${{ secrets.TF_INTERNAL_API_KEY }}", - "test": {"fmf": { - "url": "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans", - "ref": "master", - "name": "rhel7-docker" - }}, - "environments": [{ - "arch": "x86_64", - "os": {"compose": "RHEL-7.9-Released"}, - "variables": { - "REPO_URL": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY", - "REPO_NAME": "$GITHUB_REPOSITORY", - "PR_NUMBER": "${{ steps.pr_nr.outputs.PR_NR }}", - "OS": "rhel7", - "TEST_NAME": "test" - } - }] - } - EOF - curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json - # Store REQ_ID into outputs for later on usage - echo "::set-output name=REQ_ID::$(jq -r .id response.json)" - - running: - needs: build - name: Check running tests on Testing Farm service for RHEL7 - runs-on: ubuntu-20.04 - outputs: - REQ_ID: ${{steps.req_sha.outputs.REQ_ID}} - SHA: ${{steps.req_sha.outputs.SHA}} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - name: Check if REQ_ID and SHA exists - id: req_sha - run: | - # Update ubuntu-20.04 in order to install curl and jq - # each job is separate machine - apt update && apt -y install curl jq - # Propagate REQ_ID and SHA into the finish section - echo "::set-output name=REQ_ID::${{needs.build.outputs.REQ_ID}}" - echo "::set-output name=SHA::${{needs.build.outputs.SHA}}" - - - name: Switch to running state of Testing Farm request for RHEL7 - id: running - run: | - # Create running.json file for query, whether job is finished or not. - cat << EOF > running.json - { - "sha": "${{needs.build.outputs.SHA}}", - "state": "pending", - "context": "Testing Farm - RHEL7", - "description": "Build started", - "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ needs.build.outputs.REQ_ID }}" - } - EOF - # Update GitHub status description to 'Build started' - curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.build.outputs.SHA}} \ - --data @running.json - - - name: Check test is still running - id: still_running - run: | - CMD=${{ secrets.TF_ENDPOINT }}/requests/${{needs.build.outputs.REQ_ID}} - curl $CMD > job.json - state=$(jq -r .state job.json) - # Wait till job is not finished. As soon as state is complete or failure then go to the finish action - while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do - # Wait 30s. We do not need to query Testing Farm each second - sleep 30 - curl $CMD > job.json - state=$(jq -r .state job.json) - done - - finish: - needs: running - name: Tests are finished - switching to proper state for RHEL7 - runs-on: ubuntu-20.04 - steps: - - name: Check if REQ_ID exists - run: echo "${{ needs.running.outputs.REQ_ID }}" - - - name: Check if SHA exists - run: echo "${{ needs.running.outputs.SHA }}" - - - name: Get final state of Testing Farm request for RHEL7 - id: final_state - run: | - # Update ubuntu-20.04 in order to install curl and jq - # each job is separate machine - apt update && apt -y install curl jq - curl ${{ secrets.TF_ENDPOINT }}/requests/${{needs.running.outputs.REQ_ID}} > job.json - cat job.json - state=$(jq -r .state job.json) - result=$(jq -r .result.overall job.json) - new_state="success" - infra_error=" " - echo "State is $state and result is: $result" - if [ "$state" == "complete" ]; then - if [ "$result" != "passed" ]; then - new_state="failure" - fi - else - # Mark job in case of infrastructure issues. Report to Testing Farm team - infra_error=" - Infra problems" - new_state="failure" - fi - echo "New State is: $new_state" - echo "Infra state is: $infra_error" - echo "::set-output name=FINAL_STATE::$new_state" - echo "::set-output name=INFRA_STATE::$infra_error" - - - name: Switch to final state of Testing Farm request for RHEL7 - run: | - cat << EOF > final.json - { - "sha": "${{needs.running.outputs.SHA}}", - "state": "${{steps.final_state.outputs.FINAL_STATE}}", - "context": "Testing Farm - RHEL7", - "description": "Build finished${{steps.final_state.outputs.INFRA_STATE}}", - "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ needs.running.outputs.REQ_ID }}" - } - EOF - cat final.json - # Switch Github status to proper state - curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.running.outputs.SHA}} \ - --data @final.json diff --git a/.github/workflows/rhel8-tests.yaml b/.github/workflows/rhel8-tests.yaml deleted file mode 100644 index 3e7b1723..00000000 --- a/.github/workflows/rhel8-tests.yaml +++ /dev/null @@ -1,193 +0,0 @@ -name: RHEL8-tests@TF - -on: - issue_comment: - types: - - created -jobs: - build: - # This job only runs for '[test]' pull request comments by owner, member - name: Schedule test on Testing Farm service for RHEL8 - runs-on: ubuntu-20.04 - if: | - github.event.issue.pull_request - && (contains(github.event.comment.body, '[test]') || contains(github.event.comment.body, '[test-all]')) - && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association) - outputs: - REQ_ID: ${{steps.sched_test.outputs.REQ_ID}} - SHA: ${{steps.sha.outputs.SHA}} - steps: - - name: Get pull request number - id: pr_nr - run: | - PR_URL="${{ github.event.comment.issue_url }}" - echo "::set-output name=PR_NR::${PR_URL##*/}" - - - name: Checkout repo - uses: actions/checkout@v2 - with: - ref: "refs/pull/${{ steps.pr_nr.outputs.PR_NR }}/head" - - - name: Get sha - id: sha - run: | - # Store SHA into outputs - echo "::set-output name=SHA::$(git rev-parse HEAD)" - - - name: Create status check to pending - id: pending - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - # Create a JSON file for Testing Farm in order to schedule a CI testing job - cat << EOF > pending.json - { - "sha": "${{steps.sha.outputs.SHA}}", - "state": "pending", - "context": "Testing Farm - RHEL8", - "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ steps.sched_test.outputs.req_id }}" - } - EOF - echo "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}}" - # GITHUB_TOKEN is used for updating pull request status. - # It is provided by GitHub https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret - curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{steps.sha.outputs.SHA}} \ - --data @pending.json - echo "::set-output name=GITHUB_REPOSITORY::$GITHUB_REPOSITORY" - - - name: Schedule a test on Testing Farm for RHEL 8 - id: sched_test - run: | - # Update ubuntu-20.04 in order to install curl and jq - apt update && apt -y install curl jq - cat << EOF > request.json - { - "api_key": "${{ secrets.TF_INTERNAL_API_KEY }}", - "test": {"fmf": { - "url": "https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans", - "ref": "master", - "name": "rhel8-docker" - }}, - "environments": [{ - "arch": "x86_64", - "os": {"compose": "RHEL-8.3.1-Released"}, - "variables": { - "REPO_URL": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY", - "REPO_NAME": "$GITHUB_REPOSITORY", - "PR_NUMBER": "${{ steps.pr_nr.outputs.PR_NR }}", - "OS": "rhel8", - "TEST_NAME": "test" - } - }] - } - EOF - curl ${{ secrets.TF_ENDPOINT }}/requests --data @request.json --header "Content-Type: application/json" --output response.json - # Store REQ_ID into outputs for later on usage - echo "::set-output name=REQ_ID::$(jq -r .id response.json)" - - running: - needs: build - name: Check running tests on Testing Farm service on RHEL8 - runs-on: ubuntu-20.04 - outputs: - REQ_ID: ${{steps.req_sha.outputs.REQ_ID}} - SHA: ${{steps.req_sha.outputs.SHA}} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - name: Check if REQ_ID and SHA exists - id: req_sha - run: | - # Update ubuntu-20.04 in order to install curl and jq - # each job is separate machine - apt update && apt -y install curl jq - # Propagate REQ_ID and SHA into the finish section - echo "::set-output name=REQ_ID::${{needs.build.outputs.REQ_ID}}" - echo "::set-output name=SHA::${{needs.build.outputs.SHA}}" - - - name: Switch to running state of Testing Farm request for RHEL8 - id: running - run: | - # Create running.json file for query, whether job is finished or not. - cat << EOF > running.json - { - "sha": "${{needs.build.outputs.SHA}}", - "state": "pending", - "context": "Testing Farm - RHEL8", - "description": "Build started", - "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ needs.build.outputs.REQ_ID }}" - } - EOF - # Update GitHub status description to 'Build started' - curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.build.outputs.SHA}} \ - --data @running.json - - - name: Check test is still running for RHEL8 - id: still_running - run: | - CMD=${{ secrets.TF_ENDPOINT }}/requests/${{needs.build.outputs.REQ_ID}} - curl $CMD > job.json - state=$(jq -r .state job.json) - # Wait till job is not finished. As soon as state is complete or failure then go to the finish action - while [ "$state" == "running" ] || [ "$state" == "new" ] || [ "$state" == "pending" ] || [ "$state" == "queued" ]; do - # Wait 30s. We do not need to query Testing Farm each second - sleep 30 - curl $CMD > job.json - state=$(jq -r .state job.json) - done - - finish: - needs: running - name: Tests are finished - switching to proper state for RHEL8 - runs-on: ubuntu-20.04 - steps: - - name: Check if REQ_ID exists - run: echo "${{ needs.running.outputs.REQ_ID }}" - - - name: Check if SHA exists - run: echo "${{ needs.running.outputs.SHA }}" - - - name: Get final state of Testing Farm request - id: final_state - run: | - # Update ubuntu-20.04 in order to install curl and jq - # each job is separate machine - apt update && apt -y install curl jq - curl ${{ secrets.TF_ENDPOINT }}/requests/${{needs.running.outputs.REQ_ID}} > job.json - cat job.json - state=$(jq -r .state job.json) - result=$(jq -r .result.overall job.json) - new_state="success" - infra_error=" " - echo "State is $state and result is: $result" - if [ "$state" == "complete" ]; then - if [ "$result" != "passed" ]; then - new_state="failure" - fi - else - # Mark job in case of infrastructure issues. Report to Testing Farm team - infra_error=" - Infra problems" - new_state="failure" - fi - echo "New State is: $new_state" - echo "Infra state is: $infra_error" - echo "::set-output name=FINAL_STATE::$new_state" - echo "::set-output name=INFRA_STATE::$infra_error" - - - name: Switch to final state of Testing Farm request for RHEL8 - run: | - cat << EOF > final.json - { - "sha": "${{needs.running.outputs.SHA}}", - "state": "${{steps.final_state.outputs.FINAL_STATE}}", - "context": "Testing Farm - RHEL8", - "description": "Build finished${{steps.final_state.outputs.INFRA_STATE}}", - "target_url": "http://artifacts.osci.redhat.com/testing-farm/${{ needs.running.outputs.REQ_ID }}" - } - EOF - cat final.json - # Switch Github status to proper state - curl -X POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/${{needs.running.outputs.SHA}} \ - --data @final.json diff --git a/test/test-lib-postgresql.sh b/test/test-lib-postgresql.sh index ac0acba0..19ca08bd 100644 --- a/test/test-lib-postgresql.sh +++ b/test/test-lib-postgresql.sh @@ -34,7 +34,7 @@ function test_postgresql_imagestream() { *) echo "Imagestream testing not supported for $OS environment." ; return 0 ;; esac local tag="-el7" - if [ x"${OS}" == "rhel8" ]; then + if [ "${OS}" == "rhel8" ]; then tag="-el8" fi ct_os_test_image_stream_template "${THISDIR}/../imagestreams/postgresql-${OS%[0-9]*}.json" "${THISDIR}/../examples/postgresql-ephemeral-template.json" postgresql "-p POSTGRESQL_VERSION=${VERSION}${tag}"