Skip to content

chore(docker): native multi-arch via shared workflow (#156) #273

chore(docker): native multi-arch via shared workflow (#156)

chore(docker): native multi-arch via shared workflow (#156) #273

Workflow file for this run

name: CI
on:
push:
branches:
- master
pull_request:
workflow_dispatch:
inputs:
build_image:
description: 'Build and publish Docker image'
type: boolean
default: false
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -D warnings
RUST_VERSION: 1.70.0
NODE_VERSION: '16'
jobs:
cancel-previous-runs:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}
cargo-fmt-check:
needs: cancel-previous-runs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_VERSION }}
- name: Check Formatting
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all --verbose -- --check
cargo-clippy:
needs: cancel-previous-runs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v1
- name: Check Clippy Linter
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features --all-targets -- -D warnings
cargo-check:
needs: cancel-previous-runs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v1
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: check
args: --verbose
cargo-test:
needs: cancel-previous-runs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v1
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --verbose --all --all-features
integration-test-examples:
needs: cancel-previous-runs
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq
- name: Install Fuel toolchain
run: |
curl -fsSL https://install.fuel.network/ | sh -s -- --no-modify-path
echo "$HOME/.fuelup/bin" >> $GITHUB_PATH
- name: Install fuel toolchains
run: |
source ~/.bashrc
fuelup toolchain install latest
fuelup toolchain install nightly
fuelup toolchain install testnet
fuelup toolchain install mainnet
fuelup default testnet
- name: Run integration tests for examples
run: |
source ~/.bashrc
./scripts/test-examples.sh
build-and-publish-image:
if: |
github.ref == 'refs/heads/master' ||
(github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository) ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.build_image == 'true')
needs:
- cargo-fmt-check
- cargo-clippy
- cargo-check
- cargo-test
- integration-test-examples
permissions:
contents: read
packages: write
id-token: write
uses: FuelLabs/github-actions/.github/workflows/docker-build-push.yml@master
secrets:
REGISTRY_USERNAME: ${{ github.repository_owner }}
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
with:
auth-mode: registry-login
registry: ghcr.io
build-backend: native
platforms: linux/amd64,linux/arm64
runs-on-amd64: ubuntu-latest
runs-on-arm64: ubuntu-24.04-arm
dockerfile: deployment/Dockerfile
docker-context: .
image: ghcr.io/fuellabs/sway-playground
tags: |
type=ref,event=branch
type=sha,prefix=
type=semver,pattern={{raw}}
eslint-check:
needs: cancel-previous-runs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run eslint
run: |
cd app && npm install
npm run lint-check
prettier-check:
needs: cancel-previous-runs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run prettier
run: |
cd app && npm install
npm run format-check
frontend-build-and-test:
if: github.event_name == 'pull_request'
needs:
- build-and-publish-image
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull and run image from shared workflow build
env:
IMAGE: ${{ needs.build-and-publish-image.outputs.image }}
DIGEST: ${{ needs.build-and-publish-image.outputs.digest }}
run: |
docker pull --platform linux/amd64 "${IMAGE}@${DIGEST}"
docker run -d -p 8080:8080 "${IMAGE}@${DIGEST}"
- name: NPM build and test
env:
CI: true
run: |
cd app
npm ci
npm run build
npm run test