From 8537b5d0ad8db07b30dc2376f4659fe65710d1d8 Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Wed, 7 Jun 2023 14:46:40 -0700 Subject: [PATCH] [CI] Use reusable workflow for AWS start/stop job To remove code duplication and simplify caller's code. Also, this PR moves the job to our self-hosted runner so that we don't have to wait for the Github to allocate an `ubuntu-*` runner that has unreliable waiting times. --- .github/workflows/aws.yml | 38 ++++++++++++++++ .../workflows/sycl_linux_build_and_test.yml | 45 +++++-------------- 2 files changed, 48 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/aws.yml diff --git a/.github/workflows/aws.yml b/.github/workflows/aws.yml new file mode 100644 index 0000000000000..d5606f5f4ad46 --- /dev/null +++ b/.github/workflows/aws.yml @@ -0,0 +1,38 @@ +name: Start/Stop AWS instance + +on: + workflow_call: + inputs: + mode: + description: "Mode of operation: start or stop" + type: string + required: true + + runs-on-list: + # See devops/actions/aws-ec2/action.yml for more details. + description: "JSON string with array of objects with aws-type, runs-on, aws-ami, aws-spot, aws-disk, aws-timebomb, one-job properties" + type: string + required: true + +jobs: + aws: + runs-on: cuda + environment: aws + steps: + - name: Register cleanup after job is finished + uses: ./actions/cleanup + - name: Setup script + run: | + mkdir -p ./aws-ec2 + wget raw.githubusercontent.com/intel/llvm/sycl/devops/actions/aws-ec2/action.yml -P ./aws-ec2 + wget raw.githubusercontent.com/intel/llvm/sycl/devops/actions/aws-ec2/aws-ec2.js -P ./aws-ec2 + wget raw.githubusercontent.com/intel/llvm/sycl/devops/actions/aws-ec2/package.json -P ./aws-ec2 + npm install ./aws-ec2 + - name: Start AWS EC2 runners + uses: ./aws-ec2 + with: + mode: ${{ inputs.mode }} + runs-on-list: ${{ inputs.runs-on-list }} + GH_PERSONAL_ACCESS_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} + AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }} + AWS_SECRET_KEY: ${{ secrets.AWS_SECRET_KEY }} diff --git a/.github/workflows/sycl_linux_build_and_test.yml b/.github/workflows/sycl_linux_build_and_test.yml index 1c953699e21d3..3b1414dc94851 100644 --- a/.github/workflows/sycl_linux_build_and_test.yml +++ b/.github/workflows/sycl_linux_build_and_test.yml @@ -206,23 +206,11 @@ jobs: name: Start AWS needs: build if: ${{ inputs.lts_aws_matrix != '[]' }} - runs-on: ubuntu-20.04 - environment: aws - steps: - - name: Setup script - run: | - mkdir -p ./aws-ec2 - wget raw.githubusercontent.com/intel/llvm/sycl/devops/actions/aws-ec2/action.yml -P ./aws-ec2 - wget raw.githubusercontent.com/intel/llvm/sycl/devops/actions/aws-ec2/aws-ec2.js -P ./aws-ec2 - wget raw.githubusercontent.com/intel/llvm/sycl/devops/actions/aws-ec2/package.json -P ./aws-ec2 - npm install ./aws-ec2 - - name: Start AWS EC2 runners - uses: ./aws-ec2 - with: - runs-on-list: ${{ inputs.lts_aws_matrix }} - GH_PERSONAL_ACCESS_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} - AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }} - AWS_SECRET_KEY: ${{ secrets.AWS_SECRET_KEY }} + uses: ./.github/workflows/aws.yml + secrets: inherit + with: + mode: start + runs-on-list: ${{ inputs.lts_aws_matrix }} e2e-tests: needs: [build, aws-start] @@ -324,21 +312,8 @@ jobs: # Always attempt to shutdown AWS instance, even if AWS start was not # successful. if: ${{ always() && inputs.lts_aws_matrix != '[]' }} - runs-on: ubuntu-20.04 - environment: aws - steps: - - name: Setup script - run: | - mkdir -p ./aws-ec2 - wget raw.githubusercontent.com/intel/llvm/sycl/devops/actions/aws-ec2/action.yml -P ./aws-ec2 - wget raw.githubusercontent.com/intel/llvm/sycl/devops/actions/aws-ec2/aws-ec2.js -P ./aws-ec2 - wget raw.githubusercontent.com/intel/llvm/sycl/devops/actions/aws-ec2/package.json -P ./aws-ec2 - npm install ./aws-ec2 - - name: Stop AWS EC2 runners - uses: ./aws-ec2 - with: - runs-on-list: ${{ inputs.lts_aws_matrix }} - mode: stop - GH_PERSONAL_ACCESS_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} - AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }} - AWS_SECRET_KEY: ${{ secrets.AWS_SECRET_KEY }} + uses: ./.github/workflows/aws.yml + secrets: inherit + with: + mode: stop + runs-on-list: ${{ inputs.lts_aws_matrix }}