forked from commune-ai/subspace
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added sccache to workflow and dockerfile (#12)
- Loading branch information
1 parent
d1e36c8
commit 5c97cde
Showing
4 changed files
with
109 additions
and
29 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Build and push Docker image | ||
|
||
on: | ||
push: | ||
branches: main | ||
|
||
jobs: | ||
build-n-push: | ||
permissions: write-all | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- id: commit | ||
uses: prompt/actions-commit-hash@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Docker Login | ||
uses: docker/[email protected] | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
build-args: | | ||
AWS_ACCESS_KEY_ID="${{ secrets.AWS_ACCESS_KEY_ID }}" | ||
AWS_SECRET_ACCESS_KEY="${{ secrets.AWS_SECRET_ACCESS_KEY }}" | ||
SCCACHE_BUCKET="agicommies-subspace-cache" | ||
SCCACHE_ENDPOINT="${{ vars.SCCACHE_ENDPOINT }}" | ||
SCCACHE_REGION="auto" | ||
push: true | ||
tags: ghcr.io/agicommies/subspace:${{ steps.commit.outputs.short }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,75 @@ | ||
name: Check Set-Up & Build | ||
|
||
# Controls when the action will run. | ||
on: | ||
# Triggers the workflow on push or pull request events but only for the master branch | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
check: | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-20.04 | ||
runs-on: ubuntu-22.04 | ||
|
||
concurrency: | ||
group: rust-check | ||
cancel-in-progress: true | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set-Up | ||
run: sudo apt install -y git clang curl libssl-dev llvm libudev-dev protobuf-compiler | ||
# Cache cargo's registry | ||
- name: Rust registry cache | ||
uses: Swatinem/rust-cache@v2 | ||
with: | ||
prefix-key: registry-main-cache | ||
cache-targets: false | ||
cache-on-failure: true | ||
cache-all-crates: false | ||
save-if: ${{ github.ref_name == 'main' }} | ||
|
||
- name: Install Rustup | ||
- name: Install Rust | ||
run: | | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
source ~/.cargo/env | ||
rustup default stable | ||
rustup update nightly | ||
rustup update stable | ||
rustup target add wasm32-unknown-unknown --toolchain nightly | ||
- name: Check Build | ||
rustup set profile minimal | ||
rustup show | ||
- name: Ensure the code is formatted | ||
id: fmt | ||
uses: actions-rs/cargo@v1 | ||
continue-on-error: true | ||
with: | ||
command: fmt | ||
args: -- --check | ||
|
||
- name: Install Protoc | ||
uses: arduino/setup-protoc@v1 | ||
with: | ||
version: 3.20.1 | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Install sccache | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
SCCACHE_BUCKET: "agicommies-subspace-cache" | ||
SCCACHE_ENDPOINT: ${{ vars.SCCACHE_ENDPOINT }} | ||
SCCACHE_REGION: auto | ||
run: | | ||
SKIP_WASM_BUILD=1 cargo check --release | ||
curl https://github.com/mozilla/sccache/releases/download/v0.7.6/sccache-v0.7.6-x86_64-unknown-linux-musl.tar.gz \ | ||
-Lo sccache-v0.7.6-x86_64-unknown-linux-musl.tar.gz | ||
tar -xzf sccache-v0.7.6-x86_64-unknown-linux-musl.tar.gz --strip-components=1 sccache-v0.7.6-x86_64-unknown-linux-musl/sccache | ||
./sccache --start-server | ||
echo "RUSTC_WRAPPER=${{ github.workspace }}/sccache" >> "$GITHUB_ENV" | ||
- name: Ensure Clippy is happy | ||
id: clippy | ||
uses: actions-rs/clippy-check@v1 | ||
continue-on-error: true | ||
with: | ||
args: --color=always --all-features --timings -- -D warnings | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- run: ${{ github.workspace }}/sccache --show-stats | ||
|
||
- name: Run tests | ||
run: | | ||
cargo test | ||
- name: Check Build for Benchmarking | ||
run: > | ||
pushd node && | ||
cargo check --features=runtime-benchmarks --release |
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
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