Skip to content

Commit

Permalink
ci: speedup base builds (#3994)
Browse files Browse the repository at this point in the history
* ci: speedup base builds

* ci: fix substitution

* ci: prebuild cli

* chore: testing

* ci: fix download paths

* ci: fix executables

* ci: more debug

* ci: fix perms

* ci: cleanup and rename
  • Loading branch information
viceice authored Jan 24, 2025
1 parent 3618a6e commit 8b988e3
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 32 deletions.
15 changes: 15 additions & 0 deletions .github/actions/check/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: 'Check system'
description: 'checks system status'

runs:
using: 'composite'

steps:
- name: ⚙️ Check docker service
shell: bash
run: |
systemctl status docker
- name: ⚙️ Check docker info
shell: bash
run: |
docker info
114 changes: 86 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ permissions:
jobs:
setup:
runs-on: ubuntu-22.04
timeout-minutes: 15

outputs:
uid: ${{ steps.init.outputs.uid }}

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
Expand All @@ -31,6 +36,10 @@ jobs:
with:
save-cache: true

- name: ⚙️ Init
id: init
run: echo "uid=$(uuidgen)" >> ${GITHUB_OUTPUT}

lint:
runs-on: ubuntu-22.04
needs: setup
Expand Down Expand Up @@ -114,40 +123,78 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}

base:
build:
runs-on: ubuntu-22.04
needs: setup
timeout-minutes: 15

outputs:
base: ${{ steps.init.outputs.base }}

steps:
- name: docker-config
uses: containerbase/internal-tools@4453842226e67bc5d507c41b21184cc9220f4974 # v3.5.19
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
show-progress: false

- name: 📥 Setup Node.js
uses: ./.github/actions/setup-node

- name: build
run: pnpm build

- name: upload dist
uses: actions/[email protected]
with:
command: docker-config
name: dist
path: |
dist/
base:
runs-on: ${{ matrix.arch.os }}
name: base (${{ matrix.arch.name }})
needs:
- setup
- build
timeout-minutes: 15

strategy:
fail-fast: false
matrix:
arch:
- name: x86_64
os: ubuntu-22.04
tag: amd64
- name: aarch64
os: ubuntu-22.04-arm
tag: arm64

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
show-progress: false

- name: init
id: init
- name: Check system
uses: ./.github/actions/check

- name: ⚙️ Init
run: |
export base="ttl.sh/$(uuidgen):1d"
echo "OWNER=${OWNER,,}" >> ${GITHUB_ENV}
echo "BASE=${base}" >> ${GITHUB_ENV}
echo "base=${base}" >> ${GITHUB_OUTPUT}
echo "BASE=ttl.sh/${{ needs.setup.outputs.uid }}/${{ matrix.arch.tag }}:1d" >> ${GITHUB_ENV}
- name: 📥 Setup Node.js
uses: ./.github/actions/setup-node

- name: prepare apt proxy
uses: ./.github/actions/prepare-proxy

- name: build
run: pnpm build
- name: fetch dist
uses: actions/[email protected]
with:
name: dist
path: dist

- name: fix executable
run: |
chmod +x dist/cli/*
chmod +x dist/docker/usr/local/containerbase/bin/*
chmod +x dist/docker/usr/local/sbin/*
- name: test distro
run: docker buildx bake --set build-ttl.tags=${{env.BASE}} build-ttl
Expand All @@ -161,6 +208,7 @@ jobs:
- bats
- lint
- vitest
- build
timeout-minutes: 30

strategy:
Expand All @@ -175,15 +223,14 @@ jobs:
TAG: ${{ matrix.distro }}

steps:
- name: check docker
run: |
systemctl status docker
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
show-progress: false

- name: init
- name: Check system
uses: ./.github/actions/check

- name: ⚙️ Init
run: |
echo "OWNER=${OWNER,,}" >> ${GITHUB_ENV}
Expand All @@ -193,8 +240,17 @@ jobs:
- name: prepare apt proxy
uses: ./.github/actions/prepare-proxy

- name: build
run: pnpm build
- name: fetch dist
uses: actions/[email protected]
with:
name: dist
path: dist

- name: fix executable
run: |
chmod +x dist/cli/*
chmod +x dist/docker/usr/local/containerbase/bin/*
chmod +x dist/docker/usr/local/sbin/*
- name: test distro
run: docker buildx bake test-distro --set settings.secrets=type=env,id=GITHUB_TOKEN
Expand All @@ -206,11 +262,12 @@ jobs:
runs-on: ${{ matrix.arch.os }}
name: ${{ matrix.tag }} (${{ matrix.arch.name }})
needs:
- setup
- base
- bats
- lint
- vitest
timeout-minutes: 30
timeout-minutes: 15

strategy:
max-parallel: 10
Expand Down Expand Up @@ -238,25 +295,26 @@ jobs:
arch:
- name: x86_64
os: ubuntu-22.04
tag: amd64
- name: aarch64
os: ubuntu-22.04-arm
tag: arm64

env:
TAG: ${{ matrix.tag }}

steps:
- name: check docker
run: |
systemctl status docker
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
show-progress: false

- name: init
- name: Check system
uses: ./.github/actions/check

- name: ⚙️ Init
run: |
echo "OWNER=${OWNER,,}" >> ${GITHUB_ENV}
echo "BASE_IMAGE=${{ needs.base.outputs.base }}" >> ${GITHUB_ENV}
echo "BASE_IMAGE=ttl.sh/${{ needs.setup.outputs.uid }}/${{ matrix.arch.tag }}:1d" >> ${GITHUB_ENV}
- name: 📥 Setup Node.js
uses: ./.github/actions/setup-node
Expand Down
4 changes: 0 additions & 4 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ target "build" {
target "build-ttl" {
inherits = ["settings"]
output = ["type=registry"]
platforms = [
"linux/amd64",
"linux/arm64",
]
tags = [ ]
}

Expand Down

0 comments on commit 8b988e3

Please sign in to comment.