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

Setting up GitHub actions #30

Merged
merged 5 commits into from
Apr 30, 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
64 changes: 64 additions & 0 deletions .github/workflows/build-all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Sequential Build of All Packages

on:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18' # Adjust Node.js version as necessary

- name: Build minauth
run: |
echo "Building minauth..."
cd ./minauth
npm install
npm run build
npm run test

- name: Build minauth-erc721-timelock-plugin
run: |
echo "Building minauth-erc721-timelock-plugin..."
cd ./minauth-plugins/minauth-erc721-timelock-plugin
npm install-ci
npm run build
npm run test

- name: Build minauth-merkle-membership-plugin
run: |
echo "Building minauth-merkle-membership-plugin..."
cd ./minauth-plugins/minauth-merkle-membership-plugin
npm install
npm run build
npm run test

- name: Build minauth-simple-preimage-plugin
run: |
echo "Building minauth-simple-preimage-plugin..."
cd ./minauth-plugins/minauth-simple-preimage-plugin
npm install
npm run build
npm run test

- name: Build minauth-demo-server
run: |
echo "Building minauth-demo-server..."
cd ./minauth-demo/minauth-demo-server
npm install
npm run build
npm run test

- name: Build minauth-demo-client
run: |
echo "Building minauth-demo-client..."
cd ./minauth-demo/minauth-demo-client
npm install
npm run dev-kill
npm run test
36 changes: 36 additions & 0 deletions .github/workflows/build-erc721-plugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build ERC-731 Plugin Package Workflow

on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18'

- name: Cache Node.js modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install npm packages for this package and subpackages
run: npm install-ci
working-directory: minauth-plugins/minauth-erc721-timelock-plugin

- name: Compile eth contracts & build the package using npm script
run: npm run build
working-directory: minauth-plugins/minauth-erc721-timelock-plugin
env:
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }}
SEPOLIA_PRIVATE_KEY: ${{ secrets.SEPOLIA_PRIVATE_KEY }}
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
12 changes: 12 additions & 0 deletions .github/workflows/build-merkle-memberships-plugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Build All Packages

on:
workflow_dispatch:

jobs:
build-merkle-memberships-plugin:
uses: ./.github/workflows/reusable-npm-build.yaml
with:
package_name: 'minauth-merkle-memberships-plugin'
package_path: './minauth-plugins/minauth-merkle-memberships-plugin'

11 changes: 11 additions & 0 deletions .github/workflows/build-minauth-library.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Build MinAuth Library

on:
workflow_dispatch:

jobs:
build-minauth-library:
uses: ./.github/workflows/reusable-npm-build.yaml
with:
package_name: 'minauth'
package_path: './minauth'
41 changes: 41 additions & 0 deletions .github/workflows/build-npm-package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build Plugin Simple (NPM)

on:
workflow_dispatch:
inputs:
package_name:
description: 'Name of the package'
required: true
default: 'default-package'
package_path:
description: 'Path to the package directory'
required: true
default: 'minauth-plugins/default-package'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '16' # Use the LTS version of Node.js

- name: Cache Node.js modules for ${{ github.event.inputs.package_name }}
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install dependencies in ${{ github.event.inputs.package_name }}
run: npm install
working-directory: ${{ github.event.inputs.package_path }}

- name: Build ${{ github.event.inputs.package_name }}
run: npm run build
working-directory: ${{ github.event.inputs.package_path }}
12 changes: 12 additions & 0 deletions .github/workflows/build-simple-preimage-plugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Build All Packages

on:
workflow_dispatch:

jobs:
build-simple-preimage-plugin:
uses: ./.github/workflows/reusable-npm-build.yaml
with:
package_name: 'minauth-simple-preimage-plugin'
package_path: './minauth-plugins/minauth-simple-preimage-plugin'

57 changes: 57 additions & 0 deletions .github/workflows/build-smart-on-trigger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Conditional Build on Trigger

on:
workflow_dispath:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up dependencies
run: |
sudo apt-get update
sudo apt-get install -y jq

- name: Determine Builds
id: determine-builds
run: |
# Initialize an empty array to hold packages that need building
declare -A changed_packages

# Check for changes in each package and update the list of packages that need building based on dependencies
if git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -q './minauth'; then
changed_packages["./minauth"]="minauth"
fi
if git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -q './minauth-plugins/minauth-erc721-timelock-plugin'; then
changed_packages["./minauth-plugins/minauth-erc721-timelock-plugin"]="minauth-erc721-timelock-plugin"
fi
if git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -q './minauth-plugins/minauth-merkle-membership-plugin'; then
changed_packages["./minauth-plugins/minauth-merkle-membership-plugin"]="minauth-merkle-membership-plugin"
fi
if git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -q './minauth-plugins/minauth-simple-preimage-plugin'; then
changed_packages["./minauth-plugins/minauth-simple-preimage-plugin"]="minauth-simple-preimage-plugin"
fi
if git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -q './minauth-demo/minauth-demo-server'; then
changed_packages["./minauth-demo/minauth-demo-server"]="minauth-demo-server"
fi
if git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -q './minauth-demo/minauth-demo-client'; then
changed_packages["./minauth-demo/minauth-demo-client"]="minauth-demo-client"
fi

# Convert package paths to JSON array
echo "::set-output name=packages::$(echo $(jq -nc '$ARGS.positional' --args "${!changed_packages[@]}"))"

- name: Build packages
run: |
packages=(${{ steps.determine-builds.outputs.packages }})
for package in "${packages[@]}"; do
echo "Building package: ${package}"
cd $package
npm install-ci
npm run build
cd -
done
shell: bash
45 changes: 45 additions & 0 deletions .github/workflows/reusable-npm-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Reusable Build Workflow

on:
workflow_call:
inputs:
package_name:
description: 'Name of the package'
required: true
type: string
package_path:
description: 'Path to the package directory'
required: true
type: string

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '16' # Use the LTS version of Node.js

- name: Cache Node.js modules for ${{ inputs.package_name }}
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install npm packages for this package and subpackages
run: npm install-ci
working-directory: ${{ inputs.package_path }}

- name: Build the package using the 'build' npm script
run: npm run build
working-directory: ${{ inputs.package_path }}
env:
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }}
SEPOLIA_PRIVATE_KEY: ${{ secrets.SEPOLIA_PRIVATE_KEY }}
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
4 changes: 3 additions & 1 deletion minauth-demo/minauth-demo-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
"version": "0.11.0",
"private": true,
"scripts": {
"install-ci": "npm install --unsafe-perm=true",
"dev": "next dev",
"dev-kill": "bash -c 'next dev & PID=$!; sleep 3; kill $PID; exit 0",
"dev-kill": "bash -c 'next dev & PID=$!; sleep 5; kill $PID; exit 0'",
"build": "node --max-old-space-size=8192 ./node_modules/.bin/next build",
"start": "next start",
"test": "echo \"Error: no tests here\" && exit 0",
"lint": "next lint",
"ts-watch": "tsc --noEmit --incremental --watch"
},
Expand Down
1 change: 1 addition & 0 deletions minauth-demo/minauth-demo-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"type": "module",
"main": "index.js",
"scripts": {
"install-ci": "npm install --unsafe-perm=true",
"run-client": "node ./dist/headless-test-client/index.js",
"hardhat-node": "cd eth-contract && npx hardhat node && cd ..",
"deploy-eth-contracts": "cd eth-contract && rm -rf ./ignition/deployments/chain-31337 && npx ts-node scripts/cli.ts deploy-erc721timelock --lock-period 60 && npx ts-node scripts/cli.ts deploy-erc721mock -n 'minauth_nft' -s 'MNFT' && cd ..",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

# TypeChain output
/typechain
/typechain-types

# Solidity coverage files
/coverage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { HardhatUserConfig } from 'hardhat/config';
import '@nomicfoundation/hardhat-toolbox';
import '@nomicfoundation/hardhat-ignition-ethers';
import dotenv from 'dotenv';

const env = dotenv.config().parsed;
if (!env) {
throw new Error('No .env file found');
// Directly use process.env to access environment variables
const ALCHEMY_API_KEY = process.env.ALCHEMY_API_KEY;
const SEPOLIA_PRIVATE_KEY = process.env.SEPOLIA_PRIVATE_KEY;
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY;

// Check if the required environment variables are set
if (!ALCHEMY_API_KEY || !SEPOLIA_PRIVATE_KEY || !ETHERSCAN_API_KEY) {
throw new Error('Required environment variables are not set');
}
const ALCHEMY_API_KEY = env.ALCHEMY_API_KEY;
const SEPOLIA_PRIVATE_KEY = env.SEPOLIA_PRIVATE_KEY;
const ETHERSCAN_API_KEY = env.ETHERSCAN_API_KEY;

const config: HardhatUserConfig = {
solidity: '0.8.20',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"test": "test"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"compile": "npx hardhat compile"
},
"keywords": [],
"author": "",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type * as interfaces from "./interfaces";
export type { interfaces };
import type * as token from "./token";
export type { token };
import type * as utils from "./utils";
export type { utils };
Loading
Loading