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 71b9b90
Showing 1 changed file with 190 additions and 0 deletions.
190 changes: 190 additions & 0 deletions .github/workflows/test-linea-mainnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
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.workflow_details.outputs.id }}
tag: ${{ steps.dockertag.outputs.IMAGE }}
image: ${{ steps.dockersave.outputs.DOCKER_IMAGE }}
steps:
- name: checkout
uses: actions/checkout@v4

- 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: 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 "BUILD_DATE=$(date --rfc-3339=date)" >> ${GITHUB_ENV}
echo "Building image tag: ${{ steps.dockertag.outputs.IMAGE }}"
- 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.dockertag.outputs.IMAGE }}
VCS_REF=${{ github.sha }}
BUILD_DATE=${{ env.BUILD_DATE }}
tags: |
consensys/linea-besu-package:${{ steps.dockertag.outputs.IMAGE }}
- name: Save Docker image
id: dockersave
run: |
docker images
echo "DOCKER_IMAGE=consensys/linea-besu-package:${{ steps.dockertag.outputs.IMAGE }}" >> "$GITHUB_OUTPUT"
docker save consensys/linea-besu-package:${{ steps.dockertag.outputs.IMAGE }} -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.image}}
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 }}

0 comments on commit 71b9b90

Please sign in to comment.