feat: push compiled binary to S3 on push to github #337
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 | |
on: | |
push: | |
branches: | |
- main | |
- main-v[0-9]+.** | |
tags: | |
- v[0-9]+.** | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- auto_merge_enabled | |
- edited | |
merge_group: | |
types: [checks_requested] | |
jobs: | |
commitlint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install commitlint | |
run: npm install --global @commitlint/cli @commitlint/config-conventional | |
- name: Validate PR commits with commitlint | |
if: github.event_name == 'pull_request' && !(contains(github.event.pull_request.title, '/merge-main') || contains(github.event.pull_request.title, '/merge main')) | |
run: commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose | |
- name: Validate PR title with commitlint | |
if: github.event_name != 'merge_group' && github.event_name != 'push' && !(contains(github.event.pull_request.title, '/merge-main') || contains(github.event.pull_request.title, '/merge main')) | |
run: echo "${{ github.event.pull_request.title }}" | commitlint --verbose | |
format: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
components: rustfmt | |
toolchain: nightly-2024-01-12 | |
- uses: Swatinem/rust-cache@v2 | |
- run: scripts/rust_fmt.sh --check | |
clippy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
components: clippy | |
- uses: Swatinem/rust-cache@v2 | |
- run: scripts/clippy.sh | |
run-python-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: '3.9' | |
- run: | | |
python -m pip install --upgrade pip | |
pip install pytest | |
- run: pytest scripts/merge_paths_test.py | |
run-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
- run: cargo test | |
gcs-push: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
- name: Build CLI binary | |
run: cargo build -p committer_cli -r --bin committer_cli --target-dir ${{ github.sha }} | |
- name: Get commit hash prefix | |
id: commit_prefix | |
# run: echo "::set-output name=commit_prefix::$(echo ${{ github.sha }} | cut -c 1-7)" | |
run: echo "commit_prefix=$(echo ${{ github.sha }} | cut -c 1-7)" >> $GITHUB_OUTPUT | |
# - name: Upload binary to S3 | |
# uses: shallwefootball/s3-upload-action@master | |
# id: S3 | |
# with: | |
# aws_key_id: ${{ secrets.AWS_KEY_ID }} | |
# aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}} | |
# aws_bucket: ${{ secrets.AWS_BUCKET }} | |
# source_dir: "${{ github.sha }}/release/committer_cli" | |
# destination_dir: "${{ steps.commit_prefix.output.commit_prefix }}/release/committer_cli" | |
- id: auth | |
uses: "google-github-actions/auth@v2" | |
with: | |
credentials_json: ${{ secrets.COMMITER_PRODUCTS_EXT_WRITER_JSON }} | |
service_account: "commiter-products-ext-writer@starkware-dev.iam.gserviceaccount.com" | |
- name: Upload binary to GCP | |
id: upload_file | |
uses: "google-github-actions/upload-cloud-storage@v2" | |
with: | |
path: "${{ github.sha }}/release/committer_cli" | |
destination: "committer-products-external/${{ join(steps.commit_prefix.outputs.*, '') }}/release/" | |
udeps: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@master | |
name: "Rust Toolchain Setup" | |
with: | |
toolchain: nightly-2024-01-12 | |
- uses: Swatinem/rust-cache@v2 | |
id: "cache-cargo" | |
- if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }} | |
name: "Download and run cargo-udeps" | |
run: | | |
wget -O - -c https://github.com/est31/cargo-udeps/releases/download/v0.1.45/cargo-udeps-v0.1.45-x86_64-unknown-linux-gnu.tar.gz | tar -xz | |
cargo-udeps-*/cargo-udeps udeps | |
env: | |
RUSTUP_TOOLCHAIN: nightly-2024-01-12 | |
all-tests: | |
runs-on: ubuntu-latest | |
needs: | |
- clippy | |
- commitlint | |
- format | |
- run-python-tests | |
- run-tests | |
- udeps | |
steps: | |
- name: Decide whether all the needed jobs succeeded or failed | |
uses: re-actors/[email protected] | |
with: | |
jobs: ${{ toJSON(needs) }} |