Skip to content

Commit

Permalink
feat: add workflow for docker image push (#52)
Browse files Browse the repository at this point in the history
* feat: add workflow for docker image push

* chore: update workflow name
  • Loading branch information
V00D00-child authored Dec 16, 2023
1 parent a000ea7 commit 534d8f0
Show file tree
Hide file tree
Showing 17 changed files with 201 additions and 140 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build, Lint, and Test

on:
workflow_call:

jobs:
build-lint-test:
name: Build, Lint, and Test
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v3
- name: Build with Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: npm install --no-package-lock
- run: npm install --save-dev @nomicfoundation/solidity-analyzer-linux-x64-gnu @nx/nx-linux-x64-gnu
- name: Build
run: npm run build
- name: Lint
run: npm run lint
- name: Test
run: npm run test
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
41 changes: 0 additions & 41 deletions .github/workflows/build.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
name: compliance

on:
push:
branches: [ "main" ]
pull_request:
branches:
- '**'
workflow_call:

jobs:
bundler-spec-tests:
compliance:
name: compliance
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x]

matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v3

Expand All @@ -25,7 +20,7 @@ jobs:
uses: "actions/setup-node@v3"
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache: "npm"

- name: Checkout bundler spec tests
uses: actions/checkout@v3
Expand Down Expand Up @@ -76,10 +71,10 @@ jobs:
--exec "eth.sendTransaction({from: eth.accounts[0], to: \"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266\", value: web3.toWei(4337, \"ether\")})" \
attach http://localhost:8545/
- name: Install Transeptor deps
- name: Install Transeptor deps
run: npm install --no-package-lock
- name: Install Transeptor build tool deps

- name: Install Transeptor build tool deps
run: npm install --save-dev @nx/nx-linux-x64-gnu

- name: Build Transeptor
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Create Release Pull Request

on:
workflow_dispatch:
inputs:
base-branch:
description: "The base branch for git operations and the pull request."
default: "main"
required: true
release-version:
description: "A specific version to bump to, i.e. 0.1.1"
required: true

env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # setting GH_TOKEN for the entire workflow

jobs:
create-release-pr:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 14

- name: Configure Git identity
run: |
git config user.email "[email protected]"
git config user.name "GitHub Actions"
- name: Create release branch
run: |
branch_name="release/v${{ github.event.inputs.release-version }}"
git checkout -b $branch_name
git commit --allow-empty -m "Release v${{ github.event.inputs.release-version }}"
git push origin $branch_name
echo "::set-output name=branch_name::$branch_name"
- name: Open Pull Request
run: |
gh pr create --base ${{ github.event.inputs.base-branch }} --head "release/v${{ github.event.inputs.release-version }}" --title "Release v${{ github.event.inputs.release-version }}" --body "Automated release PR for version v${{ github.event.inputs.release-version }}"
64 changes: 64 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Main

on:
push:
branches: [main]
pull_request:

jobs:
build-lint-test:
uses: ./.github/workflows/build-lint-test.yml

compliance:
uses: ./.github/workflows/compliance.yml

all-jobs-completed:
name: All jobs completed
runs-on: ubuntu-latest
needs:
- build-lint-test
outputs:
PASSED: ${{ steps.set-output.outputs.PASSED }}
steps:
- name: Set PASSED output
id: set-output
run: echo "PASSED=true" >> "$GITHUB_OUTPUT"

all-jobs-pass:
name: All jobs pass
if: ${{ always() }}
runs-on: ubuntu-latest
needs: all-jobs-completed
steps:
- name: Check that all jobs have passed
run: |
passed="${{ needs.all-jobs-completed.outputs.PASSED }}"
if [[ $passed != "true" ]]; then
exit 1
fi
is-release:
# Filtering by `push` events ensures that we only release from the `main` branch, which is a
# requirement for our npm publishing environment.
# The commit author should always be 'github-actions' for releases created by the
# 'create-release-pr' workflow, so we filter by that as well to prevent accidentally
# triggering a release.
if: github.event_name == 'push' && startsWith(github.event.head_commit.author.name, 'github-actions')
needs: all-jobs-pass
outputs:
IS_RELEASE: ${{ steps.is-release.outputs.IS_RELEASE }}
runs-on: ubuntu-latest
steps:
- uses: MetaMask/action-is-release@v1
id: is-release

publish-release:
needs: is-release
if: needs.is-release.outputs.IS_RELEASE == 'true'
name: Publish Release transeptor docker image
permissions:
contents: write
uses: ./.github/workflows/publish-release.yml
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
38 changes: 38 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Publish Release transeptor docker image

on:
workflow_call:
secrets:
DOCKER_USERNAME:
required: true
DOCKER_PASSWORD:
required: true

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Get package version
id: get_version
run: echo version=$(node -p "require('./package.json').version") >> $GITHUB_OUTPUT

- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm64/v8
file: ./Dockerfile
push: true
tags: |
transeptorlabs/bundler:${{ steps.get_version.outputs.version }}
transeptorlabs/bundler:latest
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<p align="center">
<img src="https://img.shields.io/badge/node-18.x-green" alt="Node Version">
<img src="https://badgen.net/badge/-/TypeScript?icon=typescript&label&labelColor=blue&color=555555" alt="TypeScript">
<img src="https://github.com/transeptorlabs/transeptor-bundler/actions/workflows/build.yml/badge.svg?branch=main">
<img src="https://github.com/transeptorlabs/transeptor-bundler/actions/workflows/bundler-spec-test.yml/badge.svg?branch=main">
<img src="https://github.com/transeptorlabs/transeptor-bundler/actions/workflows/main.yml/badge.svg?branch=main">
<img src="https://github.com/transeptorlabs/transeptor-bundler/actions/workflows/compliance.yml/badge.svg?branch=main">
<a href="https://app.codecov.io/gh/transeptorlabs/transeptor-bundler">
<img src="https://img.shields.io/codecov/c/github/transeptorlabs/transeptor-bundler.svg?style=flat-square" alt="codecov">
</a>
Expand Down
18 changes: 0 additions & 18 deletions docker-image-release-notes.md

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "root",
"version": "0.5.0-alpha.0",
"author": {
"name": "Transeptor Labs",
"email": "[email protected]",
Expand All @@ -14,7 +15,6 @@
"bugs": {
"url": "https://github.com/transeptorlabs/transeptor-bundler/issues"
},
"private": true,
"scripts": {
"///ab": "_____________________________________________________________________",
"///cv": "________________________WELCOME BUILDERS______________________________",
Expand Down
12 changes: 3 additions & 9 deletions packages/bundle/src/BundleProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export class BundleProcessor {
*/
public async sendNextBundle(isAuto = false): Promise<SendBundleReturn> {
if (this.mempoolManager.size() === 0) {
Logger.debug('Mempool size is 0 - no user ops to bundle')
return {
transactionHash: '',
userOpHashes: []
Expand All @@ -69,20 +68,17 @@ export class BundleProcessor {
? await this.mempoolManager.getAllPending()
: await this.mempoolManager.getNextPending()

Logger.debug(`Got entries from mempool: ${entries.length}`)
const [bundle, storageMap] = await this.createBundle(entries)
Logger.debug({ length: bundle.length, bundle }, 'bundle created')

if (bundle.length === 0) {
Logger.debug('sendNextBundle - no bundle to send')
return {
transactionHash: '',
userOpHashes: []
}
} else {
const beneficiary = await this.selectBeneficiary()
const ret = await this.sendBundle(bundle, beneficiary, storageMap)
Logger.debug(`sendNextBundle exit - after sent a bundle of ${bundle.length} `)
return ret
}
}
Expand Down Expand Up @@ -225,17 +221,15 @@ export class BundleProcessor {
ret = await this.providerService.send('eth_sendRawTransactionConditional', [
signedTx, { knownAccounts: storageMap }
])
Logger.debug({ret}, 'eth_sendRawTransactionConditional ret=')
Logger.debug({ret, length: userOps.length}, 'eth_sendRawTransactionConditional ret=')
} else {
// ret = await this.signer.sendTransaction(tx)
ret = await this.providerService.send('eth_sendRawTransaction', [signedTx])
Logger.debug({ret}, 'eth_sendRawTransaction ret=')
Logger.debug({ret, length: userOps.length}, 'eth_sendRawTransaction ret=')
}

// TODO: parse ret, and revert if needed.
// Logger.debug({ret}, 'ret=')
Logger.debug({length: userOps.length}, 'sent handleOps')


// hashes are needed for debug rpc only.
const hashes = await this.getUserOpHashes(userOps)
return {
Expand Down
2 changes: 0 additions & 2 deletions packages/cli/src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,8 @@ export class Config {
throw new Error('ALCHEMY_API_KEY env var not set')
}

Logger.debug(`Using remote eth client at ${programOpts.network as string}`)
this.provider = this.getNetworkProvider(programOpts.network as string, process.env.ALCHEMY_API_KEY as string)
} else {
Logger.debug(`Using local eth client at ${programOpts.network as string}`)
this.provider = this.getNetworkProvider(programOpts.network as string)
}

Expand Down
Loading

0 comments on commit 534d8f0

Please sign in to comment.