1name: Linux
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  # CCache is disabled for the Linux jobs for now.
19  CCACHE_SIZE: "0M"
20  CCACHE_CMD: true
21  DOCKERFILE: picolibc/.github/Dockerfile
22  IMAGE_FILE: dockerimg-linux.tar.zst
23  IMAGE: picolibc-linux
24  PACKAGES_FILE: picolibc/.github/linux-packages.txt
25  EXTRA_FILE: picolibc/.github/linux-files.txt
26
27jobs:
28  cache-maker:
29    runs-on: ubuntu-latest
30    steps:
31      - name: Clone picolibc
32        uses: actions/checkout@v4
33        with:
34          path: picolibc
35
36      - name: Cache the Docker Image
37        id: cache
38        uses: actions/cache@v4
39        with:
40          path: ${{ env.IMAGE_FILE }}
41          key: ${{ env.IMAGE_FILE }}-${{ hashFiles( env.DOCKERFILE, env.PACKAGES_FILE, env.EXTRA_FILE ) }}
42          lookup-only: true
43
44      - name: Set up Docker Buildx
45        if: steps.cache.outputs.cache-hit != 'true'
46        uses: docker/setup-buildx-action@v3
47
48      - name: Build picolibc container
49        if: steps.cache.outputs.cache-hit != 'true'
50        uses: docker/build-push-action@v5
51        with:
52          platforms: linux/amd64
53          file: .github/Dockerfile
54          tags: ${{ env.IMAGE }}:latest
55          outputs: type=docker,force-compression=true,compression=zstd,compression-level=22,dest=${{ env.IMAGE_FILE }}
56
57