Skip to content

Commit

Permalink
Ci (#2)
Browse files Browse the repository at this point in the history
* Use crates.io crates, fix spell-check and build

* CI: Add scripts and repo setup

#### Problem

This repo only contains the implementation of the program / CLI / JS /
python bindings, with no way of testing that any of it works.

#### Summary of changes

Get this repo in shape, based on the memo repo. Does the following:

* add CI for testing during PRs
* add dependabot
* add scripts
* add Cargo workspace
* add license
* add toolchain file / format file
* update maintainers to Anza
* add publish scripts for JS and CLI
* fix build issues

* (Temporary) always run CI

* Add more deps for CLI build

* Add purge step

* Revert "(Temporary) always run CI"

This reverts commit 3c640f6.
  • Loading branch information
joncinque authored Dec 11, 2024
1 parent 07a4789 commit f15cd3a
Show file tree
Hide file tree
Showing 49 changed files with 14,196 additions and 79 deletions.
133 changes: 133 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Setup environment

inputs:
cargo-cache-key:
description: The key to cache cargo dependencies. Skips cargo caching if not provided.
required: false
cargo-cache-fallback-key:
description: The fallback key to use when caching cargo dependencies. Default to not using a fallback key.
required: false
cargo-cache-local-key:
description: The key to cache local cargo dependencies. Skips local cargo caching if not provided.
required: false
clippy:
description: Install Clippy if `true`. Defaults to `false`.
required: false
rustfmt:
description: Install Rustfmt if `true`. Defaults to `false`.
required: false
solana:
description: Install Solana if `true`. Defaults to `false`.
required: false
cli:
description: Install CLI dependencies if `true`. Defaults to `false`.
required: false
purge:
description: Purge unused directories if `true`. Defaults to `false`.
required: false

runs:
using: 'composite'
steps:
- name: Setup pnpm
uses: pnpm/action-setup@v3

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- name: Purge unused ubuntu runner directories
if: ${{ inputs.purge == 'true' }}
shell: bash
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/share/swift
sudo rm -rf /usr/share/mysql
sudo rm -rf /usr/share/az_*
sudo rm -rf /usr/share/postgresql-common
sudo rm -rf /opt/ghc
sudo rm -rf /opt/az
sudo rm -rf /opt/pipx
sudo rm -rf /opt/microsoft
sudo rm -rf /opt/google
sudo rm -rf /opt/hostedtoolcache
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/local/lib/heroku
sudo rm -rf /imagegeneration
- name: Install Dependencies
run: pnpm install --frozen-lockfile
shell: bash

- name: Set Environment Variables
shell: bash
run: pnpm zx ./scripts/ci/set-env.mjs

- name: Install Rustfmt
if: ${{ inputs.rustfmt == 'true' }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.TOOLCHAIN_FORMAT }}
components: rustfmt

- name: Install Clippy
if: ${{ inputs.clippy == 'true' }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.TOOLCHAIN_LINT }}
components: clippy

- name: Install Solana
if: ${{ inputs.solana == 'true' }}
uses: solana-program/actions/install-solana@v1
with:
version: ${{ env.SOLANA_VERSION }}
cache: true

- name: Install CLI dependencies
if: ${{ inputs.cli == 'true' }}
shell: bash
run: sudo apt install libudev-dev -y

- name: Cache Cargo Dependencies
if: ${{ inputs.cargo-cache-key && !inputs.cargo-cache-fallback-key }}
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ inputs.cargo-cache-key }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-${{ inputs.cargo-cache-key }}

- name: Cache Cargo Dependencies With Fallback
if: ${{ inputs.cargo-cache-key && inputs.cargo-cache-fallback-key }}
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ inputs.cargo-cache-key }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ inputs.cargo-cache-key }}
${{ runner.os }}-${{ inputs.cargo-cache-fallback-key }}-${{ hashFiles('**/Cargo.lock') }}
${{ runner.os }}-${{ inputs.cargo-cache-fallback-key }}
- name: Cache Local Cargo Dependencies
if: ${{ inputs.cargo-cache-local-key }}
uses: actions/cache@v4
with:
path: |
.cargo/bin/
.cargo/registry/index/
.cargo/registry/cache/
.cargo/git/db/
key: ${{ runner.os }}-${{ inputs.cargo-cache-local-key }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-${{ inputs.cargo-cache-local-key }}
21 changes: 21 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: cargo
directory: "/"
schedule:
interval: daily
time: "08:00"
timezone: UTC
open-pull-requests-limit: 6
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
time: "09:00"
timezone: UTC
open-pull-requests-limit: 6
17 changes: 17 additions & 0 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Dependabot auto-merge
on: pull_request

permissions:
contents: write
pull-requests: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'solana-program/stake-pool'
steps:
- name: Enable auto-merge
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading

0 comments on commit f15cd3a

Please sign in to comment.