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

ci: add base workflows #13

Merged
merged 5 commits into from
Sep 22, 2023
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
12 changes: 6 additions & 6 deletions .github/actions/action.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: 'Gomu Gomu no Gatling'
description: 'Run Gomu Gomu no Gatling to benchmark Starknet Sequencers'
name: "Gomu Gomu no Gatling"
description: "Run Gomu Gomu no Gatling to benchmark Starknet Sequencers"
branding:
icon: 'activity-circle'
color: 'orange'
icon: "activity-circle"
color: "orange"
inputs:
config_path:
description: 'Path to the configuration file'
description: "Path to the configuration file"
required: true
runs:
using: 'composite'
using: "composite"
steps:
- run: cargo build --release
shell: bash
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/binaries-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
name: Task - Build binaries and publish

on:
workflow_dispatch:
inputs:
release_tag_name:
description: "Release tag name"
type: string
required: true
workflow_call:
inputs:
release_tag_name:
description: "Release tag name"
type: string
required: true

jobs:
build:
strategy:
fail-fast: false
matrix:
build:
- aarch64-apple-darwin
- aarch64-unknown-linux-gnu
- x86_64-apple-darwin
- x86_64-unknown-linux-gnu
# - x86_64-pc-windows-gnu
- x86_64-pc-windows-msvc
include:
- build: aarch64-apple-darwin
os: macos-latest
bin_name: madara
- build: aarch64-unknown-linux-gnu
os: ubuntu-latest
bin_name: madara
- build: x86_64-apple-darwin
os: macos-latest
bin_name: madara
- build: x86_64-unknown-linux-gnu
os: ubuntu-latest
bin_name: madara
- build: x86_64-pc-windows-msvc
os: windows-latest
bin_name: madara.exe
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup rust toolchain
run: |
rustup target add ${{ matrix.build }}

- name: Build binaries
run: cargo build --release --target ${{ matrix.build }}

- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/${{ matrix.build }}/release/${{ matrix.bin_name }}
asset_name: ${{ matrix.build}}-${{ matrix.bin_name }}
tag: ${{ inputs.release_tag_name }}
overwrite: true
20 changes: 20 additions & 0 deletions .github/workflows/cron-daily.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Workflow - Daily Cron

on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"

jobs:
stale_issues:
name: Stale issues
uses: ./.github/workflows/stale-issues.yml

lock_closed:
name: Lock closed issues/PRs
uses: ./.github/workflows/lock-closed.yml

security_audit:
name: Security audit
uses: ./.github/workflows/security-audit.yml
115 changes: 115 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
---
name: Task - Build and Push Docker Image

on:
workflow_dispatch:
inputs:
release_tag_name:
description: "Release tag name"
type: string
required: true
workflow_call:
inputs:
release_tag_name:
description: "Release tag name"
type: string
required: true

env:
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=raw,value=${{ inputs.release_tag_name }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push by digest
id: build
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE
}},push-by-digest=true,name-canonical=true,push=true

- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"

- name: Upload digest
uses: actions/upload-artifact@v3
with:
name: digests
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v3
with:
name: digests
path: /tmp/digests

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY_IMAGE }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)

- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
34 changes: 34 additions & 0 deletions .github/workflows/linters-cargo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: Task - Linters Cargo

on:
workflow_dispatch:
workflow_call:

jobs:
cargo-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Retrieve cached build
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}-${{
github.run_id }}
fail-on-cache-miss: true
restore-keys: |
${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}-${{
github.run_id }}
${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
${{ runner.os }}-cargo
- name: Format and clippy
run: |
cargo fmt -- --check
cargo clippy --no-deps -- -D warnings
cargo clippy --tests --no-deps -- -D warnings
15 changes: 15 additions & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: Task - Linters

on:
workflow_dispatch:
workflow_call:

jobs:
prettier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run prettier
run: |-
npx prettier --check .
31 changes: 31 additions & 0 deletions .github/workflows/lock-closed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: Task - Lock Closed Issues/PRs

on:
workflow_dispatch:
workflow_call:

jobs:
lock:
name: 🔒 Lock closed issues and PRs
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v2.0.3
with:
github-token: ${{ github.token }}
issue-lock-inactive-days: "30"
issue-lock-reason: ""
issue-comment: >
Issue closed and locked due to lack of activity.

If you encounter this same issue, please open a new issue and refer
to this closed one.
pr-lock-inactive-days: "1"
pr-lock-reason: ""
pr-comment: >
Pull Request closed and locked due to lack of activity.

If you'd like to build on this closed PR, you can clone it using
this method: https://stackoverflow.com/a/14969986

Then open a new PR, referencing this closed PR in your message.
42 changes: 42 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: Task - Pre-Release

on:
workflow_dispatch:
workflow_call:

jobs:
build:
name: Take Snapshot
runs-on: ubuntu-latest
steps:
- name: Get the tags by date
id: tags
run: |
echo "new=$(date +'weekly-%Y-%m-%d')" >> $GITHUB_OUTPUT
echo "old=$(date -d'1 week ago' +'weekly-%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Checkout branch "main"
uses: actions/checkout@v3
with:
ref: "main"
fetch-depth: 0
- name: Generate changelog
id: changelog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "# Automatic snapshot pre-release ${{ steps.tags.outputs.new }}" > Changelog.md
echo "" >> Changelog.md
echo "## Changes since last snapshot (${{ steps.tags.outputs.old }})" >> Changelog.md
echo "" >> Changelog.md
- name: Release snapshot
id: release-snapshot
uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # v1.1.4 latest version, repo archived
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tags.outputs.new }}
release_name: ${{ steps.tags.outputs.new }}
draft: false
prerelease: true
body_path: Changelog.md
21 changes: 21 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Workflow - Pull Request

on:
workflow_dispatch:
pull_request:
branches: [main]

jobs:
linters:
name: Run linters
uses: ./.github/workflows/linters.yml

rust_build:
name: Build Rust project
uses: ./.github/workflows/rust-build.yml

linters_cargo:
name: Run Cargo linters
uses: ./.github/workflows/linters-cargo.yml
needs: rust_build
21 changes: 21 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Workflow - Push

on:
workflow_dispatch:
push:
branches: [main]

jobs:
linters:
name: Run linters
uses: ./.github/workflows/linters.yml

rust_build:
name: Build Rust project
uses: ./.github/workflows/rust-build.yml

linters_cargo:
name: Run Cargo linters
uses: ./.github/workflows/linters-cargo.yml
needs: rust_build
Loading