Skip to content

Commit

Permalink
into development
Browse files Browse the repository at this point in the history
  • Loading branch information
4meta5 committed Jul 10, 2024
2 parents f9e7189 + 2ce1751 commit 1a7e77d
Show file tree
Hide file tree
Showing 53 changed files with 412 additions and 982 deletions.
85 changes: 85 additions & 0 deletions .github/actions/buildah-action/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: 'Buildah OCI Image'
description: 'A composite action to build OCI images using Buildah'

inputs:
image_name:
description: 'The name of the image to build'
required: true
containerfile:
description: 'Path to the Containerfile'
required: true
context:
description: 'Build context directory'
default: '.'
volume:
description: 'Optional volume bind mount'
required: false
username:
description: 'Registry username'
required: false
password:
description: 'Registry password'
required: false
registry:
description: 'Registry URL'
required: false
build_args:
description: 'Optional build arguments for Buildah'
required: false
push:
description: 'Push the image to the registry'
required: false
tags:
description: 'Image tags'
required: false

runs:
using: "composite"
steps:
- name: Setup environment
shell: bash
run: |
buildah -h
if [ $? -ne 0 ]; then
sudo apt-get update
sudo apt-get install -y buildah
fi
- name: Build the image
shell: bash
run: |
VOLUME_OPTION=""
if [ -n "${{ inputs.volume }}" ]; then
VOLUME_OPTION="--volume ${{ inputs.volume }}"
fi
BUILD_ARGS_OPTION=""
if [ -n "${{ inputs.build_args }}" ]; then
while IFS= read -r line; do
if [ -n "$line" ]; then
BUILD_ARGS_OPTION="$BUILD_ARGS_OPTION --build-arg $line"
fi
done <<< "${{ inputs.build_args }}"
fi
TAG_OPTIONS=""
if [ -n "${{ inputs.tags }}" ]; then
IFS=',' read -ra TAG_ARRAY <<< "${{ inputs.tags }}"
for TAG in "${TAG_ARRAY[@]}"; do
TAG_OPTIONS="$TAG_OPTIONS -t ${{ inputs.image_name }}:$TAG"
done
fi
buildah bud $VOLUME_OPTION $BUILD_ARGS_OPTION $TAG_OPTIONS --format oci -f ${{ inputs.containerfile }} -t ${{ inputs.image_name }} ${{ inputs.context }}
- name: Login to registry
shell: bash
if: ${{ inputs.push == 'true' && inputs.registry && inputs.username && inputs.password }}
run: |
echo ${{ inputs.password }} | buildah login -u ${{ inputs.username }} --password-stdin ${{ inputs.registry }}
- name: Push the image
shell: bash
if: ${{ inputs.push == 'true' }}
run: |
buildah push ${{ inputs.image_name }} ${{ inputs.registry }}/${{ inputs.image_name }}
25 changes: 18 additions & 7 deletions .github/actions/cargo-command/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,61 @@ inputs:
required: false
default: 'build'
package:
description: 'Limit execution to a specific package'
description: 'Limit execution to a specific package, assumes workspace if unset'
required: false
profile:
description: 'Profile under which to run cargo command'
required: false
default: 'release'
features:
feature:
description: 'Feature with which to run cargo command'
required: false
args:
description: 'Additional argument to pass to cargo invocation'
required: false
cache:
description: 'Whether to enable registry, index and compile output caching'
required: false
default: true
annotate:
description: 'Whether to provide errors as GitHub annotations'
required: false
default: true
runs:
using: "composite"
steps:
- name: Install rust toolchain
shell: bash
run: rustup show
- name: Install cargo-cache
if: ${{ fromJSON(inputs.annotate) }}
shell: bash
run: cargo install cargo-action-fmt
- name: Cache cargo registry and index
if: ${{ fromJSON(inputs.cache) }}
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: cargo-cache-${{ inputs.package || 'workspace' }}-${{ inputs.features || 'default' }}-${{ hashFiles('Cargo.lock') }}
key: cargo-cache-${{ inputs.package || 'workspace' }}-${{ inputs.feature || 'default' }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
cargo-cache-${{ inputs.package || 'workspace' }}-${{ inputs.features || 'default' }}-
cargo-cache-${{ inputs.package || 'workspace' }}-${{ inputs.feature || 'default' }}-
cargo-cache-${{ inputs.package || 'workspace' }}-default-
cargo-cache-workspace-
- name: Cache cargo target folder
if: ${{ fromJSON(inputs.cache) }}
uses: actions/cache@v4
with:
path: target
key: cargo-${{ inputs.command }}-${{ inputs.profile }}-${{ inputs.package || 'workspace' }}-${{ inputs.features || 'default' }}-${{ hashFiles('Cargo.lock') }}
key: cargo-${{ inputs.command }}-${{ inputs.profile }}-${{ inputs.package || 'workspace' }}-${{ inputs.feature || 'default' }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
cargo-${{ inputs.command }}-${{ inputs.profile }}-${{ inputs.package || 'workspace' }}-${{ inputs.features || 'default' }}-
cargo-${{ inputs.command }}-${{ inputs.profile }}-${{ inputs.package || 'workspace' }}-${{ inputs.feature || 'default' }}-
cargo-${{ inputs.command }}-${{ inputs.profile }}-${{ inputs.package || 'workspace' }}-default-
cargo-${{ inputs.command }}-${{ inputs.profile }}-workspace-
- name: Run cargo ${{ inputs.command }}
env:
CARGO_TERM_COLOR: always
shell: bash
run: cargo ${{ inputs.command }} ${{ inputs.package != '' && '--package' || '' }} ${{ inputs.package }} --profile '${{ inputs.profile }}' --features '${{ inputs.features }}' --message-format json ${{ inputs.args }} | cargo-action-fmt
run: cargo ${{ inputs.command }} ${{ inputs.package && '--package' || '--workspace' }} ${{ inputs.package }} --profile '${{ inputs.profile }}' --features '${{ inputs.feature }}' ${{ fromJSON(inputs.annotate) && '--message-format json' || '' }} ${{ inputs.args }} ${{ fromJSON(inputs.annotate) && '| cargo-action-fmt' || '' }}
36 changes: 19 additions & 17 deletions .github/workflows/merge-docker-chronicle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
build-binary:
name: Build Docker image
needs: ["set-tags"]
runs-on: ubuntu-latest
runs-on: ["self-hosted", "container"]
strategy:
fail-fast: false
matrix:
Expand All @@ -51,24 +51,26 @@ jobs:
steps:
- name: Fetch latest code
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
- name: Create target dir
run: mkdir -p ${{ github.workspace }}/target/${{ matrix.profile }}
- name: Cache Rust deps
uses: actions/cache@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
path: ${{ github.workspace }}/target/${{matrix.profile}}
key: docker-chronicle-${{ matrix.profile }}-${{ hashFiles('Cargo.lock', 'config/docker/Dockerfile.chronicle-release') }}
- name: Build OCI Image
uses: ./.github/actions/buildah-action
with:
image_name: ${{ env.DOCKER_REPO }}-${{ matrix.image }}:${{ needs.set-tags.outputs.commit_hash8 }}
containerfile: ./config/docker/Dockerfile.chronicle-release
context: .
push: true
tags: |
${{ env.DOCKER_REPO }}-${{ matrix.image }}:${{ needs.set-tags.outputs.commit_hash8 }}
${{ env.DOCKER_REPO }}:latest
file: config/docker/Dockerfile.chronicle-release
build-args: |-
volume: ${{ github.workspace }}/target/${{ matrix.profile }}:/build/target/${{ matrix.profile }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
registry: docker.io
push: 'true'
build_args: |
VCS_REF=${{ needs.set-tags.outputs.commit_hash8 }}
PROFILE=${{ matrix.profile }}
24 changes: 9 additions & 15 deletions .github/workflows/merge-docker-tester.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,6 @@ jobs:
uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Setup Cargo
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
Expand All @@ -68,11 +59,14 @@ jobs:
- name: Copy contracts
run: cp -r target/release/tester tester-bin
- name: Build and push
uses: docker/build-push-action@v4
uses: ./.github/actions/buildah-action
with:
image_name: ${{ env.DOCKER_REPO }}:${{ needs.set-tags.outputs.commit_hash8 }}
containerfile: ./config/docker/Dockerfile.tester-release
context: .
push: true
tags: |
${{ env.DOCKER_REPO }}:${{ needs.set-tags.outputs.commit_hash8 }}
${{ env.DOCKER_REPO }}:latest
file: config/docker/Dockerfile.tester-release
volume: ${{ github.workspace }}/target:/build/target
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
registry: docker.io
push: 'true'

36 changes: 19 additions & 17 deletions .github/workflows/merge-docker-timenode.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
build-binary:
name: Build Docker image
needs: ["set-tags"]
runs-on: ubuntu-latest
runs-on: ["self-hosted", "container"]
strategy:
fail-fast: false
matrix:
Expand All @@ -45,24 +45,26 @@ jobs:
steps:
- name: Fetch latest code
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
- name: Create target dir
run: mkdir -p ${{ github.workspace }}/target/${{ matrix.profile }}
- name: Cache Rust deps
uses: actions/cache@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
path: ${{ github.workspace }}/target/${{matrix.profile}}
key: docker-timechain-${{ matrix.profile }}-${{ hashFiles('Cargo.lock', 'config/docker/Dockerfile.timenode-release') }}
- name: Build OCI Image
uses: ./.github/actions/buildah-action
with:
image_name: ${{ env.DOCKER_REPO }}-${{ matrix.image }}:${{ needs.set-tags.outputs.commit_hash8 }}
containerfile: ./config/docker/Dockerfile.timenode-release
context: .
push: true
tags: ${{ env.DOCKER_REPO }}-${{ matrix.image }}:${{ needs.set-tags.outputs.commit_hash8 }}
file: config/docker/Dockerfile.release
build-args: |
VCS_REF=${{ needs.set-tags.outputs.commit_hash8 }}
volume: ${{ github.workspace }}/target/${{ matrix.profile }}:/build/target/${{ matrix.profile }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
registry: docker.io
push: 'true'
build_args: |
PROFILE=${{ matrix.profile }}
FEATURES=${{ matrix.features }}
VCS_REF=${{ needs.set-tags.outputs.commit_hash8 }}
BUILD_VARIANT=${{ matrix.image }}
FEATURES=${{ matrix.features }}
2 changes: 1 addition & 1 deletion .github/workflows/merge-pages-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
uses: ./.github/actions/cargo-command
with:
command: doc
args: --workspace --no-deps --document-private-items
args: --no-deps --document-private-items
- name: Assemble structure
env:
DOCS_HIDEOUT: an8ohgahmoot6ro8ieReib9micau0Oow
Expand Down
46 changes: 0 additions & 46 deletions .github/workflows/pr-build-node.yaml

This file was deleted.

42 changes: 0 additions & 42 deletions .github/workflows/pr-build-tester.yaml

This file was deleted.

Loading

0 comments on commit 1a7e77d

Please sign in to comment.