Skip to content

Commit

Permalink
adding in a test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuafernandes committed Dec 10, 2024
1 parent 8a3b7b4 commit 353d237
Show file tree
Hide file tree
Showing 5 changed files with 477 additions and 58 deletions.
95 changes: 95 additions & 0 deletions .github/actions/assemble-mainnet/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
name: 'assemble-mainnet'
description: 'Composite action to assemble the mainnet artifacts'

outputs:
workflow_id:
description: workflow id
value: ${{ steps.workflowdetails.outputs.id }}

build_date:
description: build date
value: ${{ steps.workflowdetails.outputs.build_date }}

dockertag:
description: docker tag
value: ${{ steps.dockertag.outputs.dockertag }}

dockerimage:
description: docker image
value: ${{ steps.dockerimage.outputs.dockerimage }}

runs:
using: "composite"
steps:
- name: Checkout tools repo
uses: actions/checkout@v4
with:
repository: Consensys/docs-gha
path: .docs-gha

- name: get workflow_details
id: workflowdetails
run: |
echo "id=${{ github.run_id }}" >> $GITHUB_OUTPUT
echo "build_date=$(date --rfc-3339=date)" >> $GITHUB_OUTPUT
- name: get versions via dotenv
id: dotenv
uses: falti/dotenv-action@v1
with:
path: versions/linea-mainnet.env
mode: development
keys-case: lower
log-variables: true
load-mode: strict

- name: set docker tag
id: dockertag
run: |
if [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref_type }}" == "tag" ]; then
echo "dockertag=mainnet-${{ github.ref_name }}" >> $GITHUB_OUTPUT
else
echo "dockertag=mainnet-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
fi
- name: set docker image
id: dockerimage
run: |
echo "dockerimage=consensys/linea-besu-package:${{ steps.dockertag.outputs.dockertag }}" >> "$GITHUB_OUTPUT"
- name: download and untar the linea-besu archive
run: |
cd /tmp/
echo "downloading linea-besu: ${{ steps.dotenv.outputs.LINEA_BESU_TAR_GZ }}"
wget -nv "https://artifacts.consensys.net/public/linea-besu/raw/names/linea-besu.tar.gz/versions/${{ steps.dotenv.outputs.LINEA_BESU_TAR_GZ }}/linea-besu-${{ steps.dotenv.outputs.LINEA_BESU_TAR_GZ }}.tar.gz"
tar -xvf linea-besu-${{ steps.dotenv.outputs.LINEA_BESU_TAR_GZ }}.tar.gz
mv /tmp/linea-besu-${{ steps.dotenv.outputs.LINEA_BESU_TAR_GZ }} /tmp/besu
- name: copy the list of versions to the container
run: |
cp ./versions/linea-mainnet.env /tmp/besu/versions.txt
mkdir -p /tmp/besu/plugins
- name: get the plugins
run: |
cd /tmp/besu/plugins
echo "getting linea_sequencer_plugin_version: ${{ steps.dotenv.outputs.LINEA_SEQUENCER_PLUGIN_VERSION }}"
wget -nv "https://github.com/Consensys/linea-sequencer/releases/download/v${{ steps.dotenv.outputs.LINEA_SEQUENCER_PLUGIN_VERSION }}/besu-sequencer-plugins-v${{ steps.dotenv.outputs.LINEA_SEQUENCER_PLUGIN_VERSION }}.jar" -P /tmp/besu/plugins
echo "getting finalized_tag_updater_plugin_version: ${{ steps.dotenv.outputs.FINALIZED_TAG_UPDATER_PLUGIN_VERSION }}"
wget -nv "https://github.com/Consensys/linea-monorepo/releases/download/finalized-tag-updater-v${{ steps.dotenv.outputs.FINALIZED_TAG_UPDATER_PLUGIN_VERSION }}/finalized-tag-updater-v${{ steps.dotenv.outputs.FINALIZED_TAG_UPDATER_PLUGIN_VERSION }}.jar" -P /tmp/besu/plugins
echo "getting linea_tracer_plugin_version: ${{ steps.dotenv.outputs.LINEA_TRACER_PLUGIN_VERSION }}"
wget -nv "https://github.com/Consensys/linea-tracer/releases/download/v${{ steps.dotenv.outputs.LINEA_TRACER_PLUGIN_VERSION }}/linea-tracer-v${{ steps.dotenv.outputs.LINEA_TRACER_PLUGIN_VERSION }}.jar" -P /tmp/besu/plugins
echo "getting shomei_plugin_version: ${{ steps.dotenv.outputs.SHOMEI_PLUGIN_VERSION }}"
wget -nv "https://github.com/Consensys/besu-shomei-plugin/releases/download/v${{ steps.dotenv.outputs.SHOMEI_PLUGIN_VERSION }}/besu-shomei-plugin-v${{ steps.dotenv.outputs.SHOMEI_PLUGIN_VERSION }}.jar" -P /tmp/besu/plugins
- name: piece the package together to build the docker images
run: |
cd linea-besu
mv /tmp/besu ./
mv config/ genesis/ profiles/ besu/
tree .
114 changes: 57 additions & 57 deletions .github/workflows/linea-mainnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,64 +23,64 @@ jobs:
- name: checkout
uses: actions/checkout@v4

- name: get workflow_details
id: workflow_details
run: echo "id=${{ github.run_id }}" >> $GITHUB_OUTPUT
# - name: get workflow_details
# id: workflow_details
# run: echo "id=${{ github.run_id }}" >> $GITHUB_OUTPUT

- name: get versions via dotenv
id: dotenv
uses: falti/dotenv-action@v1
with:
path: versions/linea-mainnet.env
mode: development
keys-case: lower
log-variables: true
load-mode: strict

- name: set docker tag
id: dockertag
run: |
if [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref_type }}" == "tag" ]; then
echo "IMAGE=mainnet-${{ github.ref_name }}" >> $GITHUB_OUTPUT
else
echo "IMAGE=mainnet-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
fi
- name: download and untar the linea-besu archive
run: |
cd /tmp/
echo "downloading linea-besu: ${{ steps.dotenv.outputs.LINEA_BESU_TAR_GZ }}"
wget -nv "https://artifacts.consensys.net/public/linea-besu/raw/names/linea-besu.tar.gz/versions/${{ steps.dotenv.outputs.LINEA_BESU_TAR_GZ }}/linea-besu-${{ steps.dotenv.outputs.LINEA_BESU_TAR_GZ }}.tar.gz"
tar -xvf linea-besu-${{ steps.dotenv.outputs.LINEA_BESU_TAR_GZ }}.tar.gz
mv /tmp/linea-besu-${{ steps.dotenv.outputs.LINEA_BESU_TAR_GZ }} /tmp/besu
- name: copy the list of versions to the container
run: |
cp ./versions/linea-mainnet.env /tmp/besu/versions.txt
mkdir -p /tmp/besu/plugins
- name: get the plugins
run: |
cd /tmp/besu/plugins
echo "getting linea_sequencer_plugin_version: ${{ steps.dotenv.outputs.LINEA_SEQUENCER_PLUGIN_VERSION }}"
wget -nv "https://github.com/Consensys/linea-sequencer/releases/download/v${{ steps.dotenv.outputs.LINEA_SEQUENCER_PLUGIN_VERSION }}/besu-sequencer-plugins-v${{ steps.dotenv.outputs.LINEA_SEQUENCER_PLUGIN_VERSION }}.jar" -P /tmp/besu/plugins
echo "getting finalized_tag_updater_plugin_version: ${{ steps.dotenv.outputs.FINALIZED_TAG_UPDATER_PLUGIN_VERSION }}"
wget -nv "https://github.com/Consensys/linea-monorepo/releases/download/finalized-tag-updater-v${{ steps.dotenv.outputs.FINALIZED_TAG_UPDATER_PLUGIN_VERSION }}/finalized-tag-updater-v${{ steps.dotenv.outputs.FINALIZED_TAG_UPDATER_PLUGIN_VERSION }}.jar" -P /tmp/besu/plugins
echo "getting linea_tracer_plugin_version: ${{ steps.dotenv.outputs.LINEA_TRACER_PLUGIN_VERSION }}"
wget -nv "https://github.com/Consensys/linea-tracer/releases/download/v${{ steps.dotenv.outputs.LINEA_TRACER_PLUGIN_VERSION }}/linea-tracer-v${{ steps.dotenv.outputs.LINEA_TRACER_PLUGIN_VERSION }}.jar" -P /tmp/besu/plugins
echo "getting shomei_plugin_version: ${{ steps.dotenv.outputs.SHOMEI_PLUGIN_VERSION }}"
wget -nv "https://github.com/Consensys/besu-shomei-plugin/releases/download/v${{ steps.dotenv.outputs.SHOMEI_PLUGIN_VERSION }}/besu-shomei-plugin-v${{ steps.dotenv.outputs.SHOMEI_PLUGIN_VERSION }}.jar" -P /tmp/besu/plugins
- name: piece the package together to build the docker images
run: |
cd linea-besu
mv /tmp/besu ./
mv config/ genesis/ profiles/ besu/
tree .
# - name: get versions via dotenv
# id: dotenv
# uses: falti/dotenv-action@v1
# with:
# path: versions/linea-mainnet.env
# mode: development
# keys-case: lower
# log-variables: true
# load-mode: strict

# - name: set docker tag
# id: dockertag
# run: |
# if [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref_type }}" == "tag" ]; then
# echo "IMAGE=mainnet-${{ github.ref_name }}" >> $GITHUB_OUTPUT
# else
# echo "IMAGE=mainnet-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
# fi

# - name: download and untar the linea-besu archive
# run: |
# cd /tmp/
# echo "downloading linea-besu: ${{ steps.dotenv.outputs.LINEA_BESU_TAR_GZ }}"
# wget -nv "https://artifacts.consensys.net/public/linea-besu/raw/names/linea-besu.tar.gz/versions/${{ steps.dotenv.outputs.LINEA_BESU_TAR_GZ }}/linea-besu-${{ steps.dotenv.outputs.LINEA_BESU_TAR_GZ }}.tar.gz"
# tar -xvf linea-besu-${{ steps.dotenv.outputs.LINEA_BESU_TAR_GZ }}.tar.gz
# mv /tmp/linea-besu-${{ steps.dotenv.outputs.LINEA_BESU_TAR_GZ }} /tmp/besu

# - name: copy the list of versions to the container
# run: |
# cp ./versions/linea-mainnet.env /tmp/besu/versions.txt
# mkdir -p /tmp/besu/plugins

# - name: get the plugins
# run: |
# cd /tmp/besu/plugins

# echo "getting linea_sequencer_plugin_version: ${{ steps.dotenv.outputs.LINEA_SEQUENCER_PLUGIN_VERSION }}"
# wget -nv "https://github.com/Consensys/linea-sequencer/releases/download/v${{ steps.dotenv.outputs.LINEA_SEQUENCER_PLUGIN_VERSION }}/besu-sequencer-plugins-v${{ steps.dotenv.outputs.LINEA_SEQUENCER_PLUGIN_VERSION }}.jar" -P /tmp/besu/plugins

# echo "getting finalized_tag_updater_plugin_version: ${{ steps.dotenv.outputs.FINALIZED_TAG_UPDATER_PLUGIN_VERSION }}"
# wget -nv "https://github.com/Consensys/linea-monorepo/releases/download/finalized-tag-updater-v${{ steps.dotenv.outputs.FINALIZED_TAG_UPDATER_PLUGIN_VERSION }}/finalized-tag-updater-v${{ steps.dotenv.outputs.FINALIZED_TAG_UPDATER_PLUGIN_VERSION }}.jar" -P /tmp/besu/plugins

# echo "getting linea_tracer_plugin_version: ${{ steps.dotenv.outputs.LINEA_TRACER_PLUGIN_VERSION }}"
# wget -nv "https://github.com/Consensys/linea-tracer/releases/download/v${{ steps.dotenv.outputs.LINEA_TRACER_PLUGIN_VERSION }}/linea-tracer-v${{ steps.dotenv.outputs.LINEA_TRACER_PLUGIN_VERSION }}.jar" -P /tmp/besu/plugins

# echo "getting shomei_plugin_version: ${{ steps.dotenv.outputs.SHOMEI_PLUGIN_VERSION }}"
# wget -nv "https://github.com/Consensys/besu-shomei-plugin/releases/download/v${{ steps.dotenv.outputs.SHOMEI_PLUGIN_VERSION }}/besu-shomei-plugin-v${{ steps.dotenv.outputs.SHOMEI_PLUGIN_VERSION }}.jar" -P /tmp/besu/plugins

# - name: piece the package together to build the docker images
# run: |
# cd linea-besu
# mv /tmp/besu ./
# mv config/ genesis/ profiles/ besu/
# tree .

- name: set up docker buildx
uses: docker/setup-buildx-action@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linea-sepolia.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: copy the list of versions to the container
run: |
cp ./versions/linea-mainnet.env /tmp/besu/versions.txt
cp ./versions/linea-sepolia.env /tmp/besu/versions.txt
mkdir -p /tmp/besu/plugins
- name: get the plugins
Expand Down
134 changes: 134 additions & 0 deletions .github/workflows/test-linea-mainnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: test-linea-mainnet

on:
pull_request:
branches:
- main

workflow_call:
outputs:
workflow_run_id:
description: "the run id of the workflow"
value: ${{ jobs.build.outputs.workflow_run_id }}
workflow_dispatch:

permissions:
id-token: write
contents: read

jobs:
build:
runs-on: ubuntu-latest
environment: dockerhub
outputs:
workflow_run_id: ${{ steps.assemble.outputs.workflow_id }}
dockertag: ${{ steps.assemble.outputs.dockertag }}
dockerimage: ${{ steps.assemble.outputs.dockerimage }}
steps:
- name: checkout
uses: actions/checkout@v4

- name: build the linea mainnet artifacts
id: assemble
uses: ./.github/actions/assemble-mainnet

- name: set up docker buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker

- name: login to docker
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER_RW }}
password: ${{ secrets.DOCKER_PASSWORD_RW }}

- name: set docker build args
run: |
echo "Building docker tag: ${{ steps.assemble.outputs.dockertag }}"
echo "Building docker image: ${{ steps.assemble.outputs.dockerimage }}"
- name: build the image
uses: docker/build-push-action@v6
env:
DOCKER_BUILD_SUMMARY: false
with:
context: linea-besu/.
platforms: linux/amd64
provenance: false
build-args: |
VERSION=${{ steps.assemble.outputs.dockertag }}
VCS_REF=${{ github.sha }}
BUILD_DATE=${{ steps.assemble.outputs.build_date }}
tags: |
consensys/linea-besu-package:${{ steps.assemble.outputs.dockertag }}
- name: Save Docker image
id: dockersave
run: |
docker images
docker save consensys/linea-besu-package:${{ steps.assemble.outputs.dockertag }} -o /tmp/docker-image-mainnet.tar
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: docker-image-mainnet
path: /tmp/docker-image-mainnet.tar
retention-days: 1

prepare_tests:
runs-on: ubuntu-latest
needs: build
outputs:
files: ${{ steps.list.outputs.files }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Split profiles
id: list
run: |
files=$(ls linea-besu/profiles/*mainnet* | xargs -n 1 basename | sed 's/\.[^.]*$//')
files_json=$(echo "$files" | tr ' ' '\n' | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "files=$files_json" >> "$GITHUB_OUTPUT"
echo "Files: $files_json"
test-profile:
timeout-minutes: 4
runs-on: ubuntu-latest
continue-on-error: true
needs: [prepare_tests, build]
strategy:
fail-fast: false
matrix:
file: ${{ fromJSON(needs.prepare_tests.outputs.files) }}
env:
CONTAINER_NAME: linea-besu-profile-check-${{ matrix.file }}
DOCKER_IMAGE: ${{needs.build.outputs.dockerimage}}
steps:
- name: Check repository
uses: actions/checkout@v4

- name: Download artifact
uses: actions/download-artifact@v4
with:
name: docker-image-mainnet
path: /tmp

- name: Load image
run: |
docker load --input /tmp/docker-image-mainnet.tar
- name: Start container
run: |
env
COMMAND="docker run -d --name ${{ env.CONTAINER_NAME }} -e BESU_PROFILE=${{ matrix.file }} ${{ env.DOCKER_IMAGE }}"
echo $COMMAND
eval $COMMAND
- name: Verify besu container
run: bash .github/workflows/BesuContainerVerify.sh
env:
CONTAINER_NAME: ${{ env.CONTAINER_NAME }}

- name: Stop container
run: docker stop ${{ env.CONTAINER_NAME }}
Loading

0 comments on commit 353d237

Please sign in to comment.