Skip to content

Replacing S3 links #152

Replacing S3 links

Replacing S3 links #152

Workflow file for this run

name: CI on AWS GPU instance
on:
pull_request:
branches: [ "development" ]
max-concurrency: 1
# Allows to run this workflow manually from the Actions tab
workflow_dispatch:
max-concurrency: 1
env:
CI_PACKAGE_NAME: alus_github_action_ci_package_${{github.run_number}}
# For 'trigger_instance' - tty=$(readlink /proc/$$/fd/2) - possibly needed in the future, add $tty to tee command.
jobs:
package-repo:
name: Package the repo
runs-on: ubuntu-latest
outputs:
package_filename: ${{ steps.prepare-and-archive.outputs.package_filename }}
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Prepare and archive
id: prepare-and-archive
env:
CI_PACKAGE_FILENAME: ${{ env.CI_PACKAGE_NAME }}.tar.gz
CI_PACKAGE_FILENAME_PATH: /tmp/${{ env.CI_PACKAGE_NAME }}.tar.gz
run: |
$GITHUB_WORKSPACE/build-automation/create_ci_package.sh $GITHUB_WORKSPACE $CI_PACKAGE_FILENAME_PATH
echo "package_path=$CI_PACKAGE_FILENAME_PATH" >> $GITHUB_ENV
echo "package_filename=$CI_PACKAGE_FILENAME" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v4
with:
name: ${{ env.CI_PACKAGE_NAME }}
path: ${{ env.package_path }}
retention-days: 3
start-gpu-instance:
name: Start GPU instance
runs-on: ubuntu-latest
outputs:
instance_ip: ${{ steps.trigger_instance.outputs.instance_ip }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.SID_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SID_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.ALUS_SID_INSTANCE_REGION }}
- uses: actions/checkout@v3
- name: Trigger the instance
id: trigger_instance
run: |
set -o pipefail
$GITHUB_WORKSPACE/build-automation/trigger_ec2_instance.sh ${{ secrets.ALUS_SID_INSTANCE_ID }} | tee trigger_out.txt
ip_address=$(cat trigger_out.txt | tail -n 1)
echo "instance_ip=$ip_address" >> $GITHUB_OUTPUT
sleep 15
run-ci-process:
name: Build and run tests
permissions: write-all
runs-on: ubuntu-latest
needs: [start-gpu-instance, package-repo]
steps:
- name: Create SSH key
env:
SSH_PRIVATE_KEY: ${{ secrets.ALUS_CI_ACTIONS_SSH_KEY }}
run: |
key_location=~/.ssh/
mkdir -p $key_location
key_path=$key_location/id_rsa
echo "$SSH_PRIVATE_KEY" > $key_path
sudo chmod 600 $key_path
ssh-keygen -f $key_path -y > $key_path.pub
- uses: actions/download-artifact@v2
with:
name: ${{ env.CI_PACKAGE_NAME }}
- name: Transfer package
id: transfer_package
env:
INSTANCE_USERNAME: ${{ secrets.ALUS_CI_ACTIONS_USERNAME }}
run: |
instance_ip=${{ needs.start-gpu-instance.outputs.instance_ip }}
package_filename=${{ needs.package-repo.outputs.package_filename }}
instance_package_path=/tmp/$package_filename
scp -o "StrictHostKeyChecking no" $package_filename $INSTANCE_USERNAME@$instance_ip:$instance_package_path
echo "instance_package_path=$instance_package_path" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3
- name: CI process
id: ci_process
env:
INSTANCE_USERNAME: ${{ secrets.ALUS_CI_ACTIONS_USERNAME }}
run: |
instance_ip=${{ needs.start-gpu-instance.outputs.instance_ip }}
echo "Instance IP: $instance_ip"
package_path=${{ steps.transfer_package.outputs.instance_package_path }}
artifacts_test_results_location="/tmp/${{github.run_number}}"
ssh -o "StrictHostKeyChecking no" $INSTANCE_USERNAME@$instance_ip "mkdir $artifacts_test_results_location"
scp -o "StrictHostKeyChecking no" build-automation/build_and_run_in_container.sh $INSTANCE_USERNAME@$instance_ip:$artifacts_test_results_location/
set +e
ssh -o "StrictHostKeyChecking no" $INSTANCE_USERNAME@$instance_ip "cd $artifacts_test_results_location; ./build_and_run_in_container.sh $package_path $artifacts_test_results_location /home/$INSTANCE_USERNAME/alus/resources"
run_result=$?
set -e
set -x
results_location_on_runner=$artifacts_test_results_location
mkdir -p $results_location_on_runner
scp -o "StrictHostKeyChecking no" -r $INSTANCE_USERNAME@$instance_ip:$artifacts_test_results_location/alus\*/\* $results_location_on_runner/
echo "results_location=$results_location_on_runner" >> $GITHUB_OUTPUT
exit $run_result
- name: Test report generation
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Test report
path: '${{ steps.ci_process.outputs.results_location }}/*.xml,${{ steps.ci_process.outputs.results_location }}/clang/*.xml'
reporter: java-junit
stop-gpu-instance:
name: Stop GPU instance
runs-on: ubuntu-latest
needs: [start-gpu-instance, run-ci-process]
if: |
always() &&
needs.start-gpu-instance.result == 'success'
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.SID_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SID_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.ALUS_SID_INSTANCE_REGION }}
- uses: actions/checkout@v3
- name: Stop GPU instance
run: |
$GITHUB_WORKSPACE/build-automation/stop_ec2_instance.sh ${{ secrets.ALUS_SID_INSTANCE_ID }}