Optimize chore configuration #4704
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
# Controls when the action will run. | |
on: | |
# Triggers the workflow on push or pull request events but only for the master branch | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: [master] | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
start-runner: | |
name: start self-hosted EC2 runner | |
runs-on: ubuntu-latest | |
outputs: | |
label: ${{ steps.start-ec2-runner.outputs.label }} | |
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }} | |
steps: | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: Start EC2 runner | |
id: start-ec2-runner | |
uses: machulav/ec2-github-runner@v2 | |
with: | |
mode: start | |
github-token: ${{ secrets.PAT_RUNNER }} | |
ec2-image-id: ${{ secrets.EC2_IMAGE_ID_CI }} | |
ec2-instance-type: ${{ secrets.EC2_INSTANCE_TYPE }} | |
subnet-id: ${{ secrets.SUBNET_ID }} | |
security-group-id: ${{ secrets.SECURITY_GROUP_ID }} | |
aws-resource-tags: > | |
[ | |
{"Key": "Name", "Value": "${{ github.workflow }}"}, | |
{"Key": "GitHubRepository", "Value": "${{ github.repository }}"} | |
] | |
check: | |
if: github.repository == 'parallel-finance/parallel' | |
name: Auto Build CI | |
needs: start-runner | |
runs-on: ${{ needs.start-runner.outputs.label }} | |
strategy: | |
matrix: | |
os: [self-hosted] | |
rust: [nightly-2022-11-15] | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
- name: cleaning up | |
run: | | |
echo '${{ secrets.RUNNER_PASSWORD }}' | sudo -S chown -R $USER:$USER $GITHUB_WORKSPACE | |
echo "HOME=/home/ubuntu" >> ${GITHUB_ENV} | |
apt update -y && apt install git-lfs -y | |
df -hT | |
- name: Install Dependencies | |
run: | | |
echo "update apt packge ..." | |
sudo apt update -y | |
sudo apt install apt-transport-https curl ca-certificates software-properties-common -y | |
echo "add apt-get nodejs16.x and PGP" | |
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash - | |
echo "install nodejs and npm...." | |
sudo apt-get install -y nodejs | |
node -v && npm -v | |
npm install --global yarn | |
yarn --version | |
sudo apt install build-essential make cmake -y | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Install Node@16 | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 16 | |
registry-url: https://registry.npmjs.org | |
- name: Install Rust toolchain ${{ matrix.rust }} | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: ${{ matrix.rust }} | |
components: rustfmt, clippy | |
override: true | |
- name: Install wasm32-unknown-unknown for ${{ matrix.rust }} | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: ${{ matrix.rust }} | |
target: wasm32-unknown-unknown | |
override: true | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v1 | |
# # Work around https://github.com/actions/cache/issues/403 by using GNU tar | |
# # instead of BSD tar. | |
# - name: Install GNU tar | |
# if: matrix.os == 'macOS-latest' | |
# run: | | |
# brew install gnu-tar | |
# echo PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH" >> $GITHUB_ENV | |
# | |
# - name: Cache cargo registry | |
# uses: actions/cache@v1 | |
# with: | |
# path: ~/.cargo/registry | |
# key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-${{ secrets.CACHE_VERSION }} | |
# | |
# - name: Cache cargo index | |
# uses: actions/cache@v1 | |
# with: | |
# path: ~/.cargo/git | |
# key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-index-${{ hashFiles('**/Cargo.toml') }}-${{ secrets.CACHE_VERSION }} | |
# | |
# - name: Cache cargo build | |
# uses: actions/cache@v1 | |
# with: | |
# path: target | |
# key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-build-target-${{ hashFiles('**/Cargo.toml') }}-${{ secrets.CACHE_VERSION }} | |
- name: Check Build | |
run: | | |
make check | |
make check-wasm | |
make check-helper | |
- name: Check Clippy Warnings | |
run: | | |
make lint | |
- name: Check Test | |
run: | | |
make test | |
- name: Check Integration Test | |
run: | | |
make integration-test | |
stop-runner: | |
name: stop self-hosted EC2 runner | |
needs: | |
- start-runner | |
- check | |
runs-on: ubuntu-latest | |
if: ${{ always() }} | |
steps: | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: Stop EC2 runner | |
uses: machulav/ec2-github-runner@v2 | |
with: | |
mode: stop | |
github-token: ${{ secrets.PAT_RUNNER }} | |
label: ${{ needs.start-runner.outputs.label }} | |
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }} |