Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 add github-action pipeline #14

Merged
merged 4 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Rust CI - Build

on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
inputs:
node:
description: 'what to build?'
type: choice
options:
- all
- sequencer
- validator
default: all
release_type:
description: 'type of release (major|minor|hotfix)?'
type: choice
options:
- major
- minor
- hotfix
default: minor
push:
description: 'push image?'
required: true
type: boolean
default: false

jobs:
Build:
runs-on: soon-runtime-spot
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
packages: write # This is required for pushing to github registry
strategy:
matrix:
node:
- igloo
if: always() && (github.event_name == 'workflow_dispatch' || github.ref == 'tag')
steps:
- name: Check Env
run: |
printenv
if: (github.event_name == 'workflow_dispatch' && (matrix.node == github.event.inputs.node || github.event.inputs.node == 'all')) || github.ref_type == 'tag'
- name: Checkout code
uses: actions/checkout@v3
with:
path: soon
if: (github.event_name == 'workflow_dispatch' && (matrix.node == github.event.inputs.node || github.event.inputs.node == 'all')) || github.ref_type == 'tag'
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
if: (github.event_name == 'workflow_dispatch' && (matrix.node == github.event.inputs.node || github.event.inputs.node == 'all')) || github.ref_type == 'tag'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
if: (github.event_name == 'workflow_dispatch' && (matrix.node == github.event.inputs.node || github.event.inputs.node == 'all')) || github.ref_type == 'tag'
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
if: (github.event_name == 'workflow_dispatch' && (matrix.node == github.event.inputs.node || github.event.inputs.node == 'all')) || github.ref_type == 'tag'
- name: Build Docker image
uses: docker/build-push-action@v4
with:
context: "{{ defaultContext }}:./"
file: "./Dockerfile"
push: ${{ github.event.inputs.push }}
platforms: linux/amd64
tags: "ghcr.io/${{ github.repository }}/${{ matrix.node }}:${{ github.sha }}"
build-args: |-
PROFILE=debug
if: github.event_name == 'workflow_dispatch' && (matrix.node == github.event.inputs.node || github.event.inputs.node == 'all')
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: "{{ defaultContext }}:./"
file: "./Dockerfile"
push: true
platforms: linux/amd64
build-args: |-
PROFILE=release
tags: "ghcr.io/${{ github.repository }}/${{ matrix.node }}:${{ github.ref_name }}"
if: github.ref_type == 'tag'
68 changes: 68 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Rust CI - Test

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
Test:
runs-on: soon-runtime-spot
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
if: always() && ((github.event_name == 'pull_request' && (github.base_ref == 'main' || github.base_ref == 'dev')) || (github.event_name == 'push' && (format('refs/heads/{0}', 'main') == github.ref || format('refs/heads/{0}', 'dev') == github.ref)))
steps:
- name: Check Env
run: |
printenv
- name: Checkout code
uses: actions/checkout@v3
- name: Check
run: |
ls
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install Packages
uses: ConorMacBride/install-package@v1
with:
apt: >-
pkg-config
build-essential
libssl-dev
clang
libclang-dev
- name: Install solana tools
run: |
curl -L https://github.com/solana-labs/solana/releases/download/v1.18.18/solana-release-x86_64-unknown-linux-gnu.tar.bz2 -O
tar -xvjf solana-release-x86_64-unknown-linux-gnu.tar.bz2 -C ./
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.SOON_GITHUB_TOKEN }}
- name: Cache cargo registry
uses: actions/cache@v2
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache cargo build
uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-
- name: Run tests
run: |-
export PATH="./solana-release/bin:$PATH"
which solana-keygen
make test
working-directory: "./"
Loading