1name: Zephyr
2
3on:
4  push:
5    branches:
6      - main
7  pull_request:
8    branches:
9      - main
10
11# When a PR is updated, cancel the jobs from the previous version. Merges
12# do not define head_ref, so use run_id to never cancel those jobs.
13concurrency:
14  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
15  cancel-in-progress: true
16
17env:
18  # .github/do-zephyr --buildtype release
19  # is the largest cache, 429.5M (September 2023).
20  CCACHE_SIZE: "450M"
21  CCACHE_CMD: ccache
22  DOCKERFILE: picolibc/.github/Dockerfile-zephyr
23  IMAGE_FILE: dockerimg-zephyr.tar.zst
24  IMAGE: picolibc
25  PACKAGES_FILE: picolibc/.github/zephyr-packages.txt
26  EXTRA_FILE: picolibc/.github/zephyr-files.txt
27
28jobs:
29  cache-maker:
30    runs-on: ubuntu-latest
31    steps:
32      - name: Clone picolibc
33        uses: actions/checkout@v4
34        with:
35          path: picolibc
36
37      - name: Cache the Docker Image
38        id: cache
39        uses: actions/cache@v4
40        with:
41          path: ${{ env.IMAGE_FILE }}
42          key: ${{ env.IMAGE_FILE }}-${{ hashFiles( env.DOCKERFILE, env.PACKAGES_FILE, env.EXTRA_FILE ) }}
43          lookup-only: true
44
45      - name: Set up Docker Buildx
46        if: steps.cache.outputs.cache-hit != 'true'
47        uses: docker/setup-buildx-action@v3
48
49      - name: Build picolibc container
50        if: steps.cache.outputs.cache-hit != 'true'
51        uses: docker/build-push-action@v5
52        with:
53          platforms: linux/amd64
54          file: .github/Dockerfile-zephyr
55          tags: ${{ env.IMAGE }}:latest
56          outputs: type=docker,force-compression=true,compression=zstd,compression-level=22,dest=${{ env.IMAGE_FILE }}
57
58