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 minsize-zephyr: 59 needs: cache-maker 60 runs-on: ubuntu-latest 61 strategy: 62 matrix: 63 meson_flags: [ 64 "", 65 66 # Tinystdio and math configurations, one with multithread disabled and with locale, original malloc and atexit/onexit code 67 "-Dio-float-exact=false -Dio-long-long=true -Dio-percent-b=true -Dio-long-double=true -Dnewlib-obsolete-math=false -Dwant-math-errno=true -Dnewlib-multithread=false -Dnewlib-retargetable-locking=false -Dnewlib-locale-info=true -Dnewlib-locale-info-extended=true -Dnewlib-mb=true -Dnewlib-iconv-external-ccs=true -Dnewlib-nano-malloc=false -Dpicoexit=false -Dprintf-small-ultoa=true", 68 "-Dformat-default=integer -Dfreestanding=true -Dposix-io=false -Dnewlib-obsolete-math=true -Dwant-math-errno=true -Dassert-verbose=false -Dfast-bufio=true", 69 70 # Original stdio, one with multithread disabled 71 "-Dtinystdio=false", 72 "-Dtinystdio=false -Dnewlib-io-float=true -Dio-long-long=true -Dio-long-double=true -Dnewlib-fvwrite-in-streamio=true -Dnewlib-multithread=false -Dnewlib-retargetable-locking=false", 73 ] 74 test: [ 75 "./.github/do-zephyr", 76 ] 77 steps: 78 - name: Clone picolibc 79 uses: actions/checkout@v4 80 with: 81 path: picolibc 82 83 - name: Restore the Docker Image 84 uses: actions/cache@v4 85 with: 86 path: ${{ env.IMAGE_FILE }} 87 key: ${{ env.IMAGE_FILE }}-${{ hashFiles( env.DOCKERFILE, env.PACKAGES_FILE, env.EXTRA_FILE ) }} 88 fail-on-cache-miss: true 89 90 - name: Load and Check the Docker Image 91 run: | 92 docker load -i $IMAGE_FILE 93 docker images -a $IMAGE 94 95 # The docker image contains ccache, but the ccache action uses the ccache 96 # outside docker for statistics, so install the same ccache version. 97 # Install in /usr/bin so the ccache action gets the expected environment. 98 - name: install ccache 99 if: matrix.test == './.github/do-zephyr' 100 run: | 101 wget -nv https://github.com/ccache/ccache/releases/download/v4.8.2/ccache-4.8.2-linux-x86_64.tar.xz 102 sudo tar xf ccache-4.8.2-linux-x86_64.tar.xz -C /usr/bin --strip-components=1 --no-same-owner ccache-4.8.2-linux-x86_64/ccache 103 rm -f ccache-*-linux-x86_64.tar.xz 104 105 # Key on job name and cache size to get separate caches for linux 106 # and zephyr. 107 - name: ccache 108 if: matrix.test == './.github/do-zephyr' 109 uses: hendrikmuhs/ccache-action@v1.2.11 110 with: 111 key: compilation-${{ runner.os }}-${{ github.job }}-${{ matrix.meson_flags }}-${{ env.CCACHE_SIZE }} 112 max-size: ${{ env.CCACHE_SIZE }} 113 114 - name: Minsize test 115 run: | 116 docker run -v $(readlink -f picolibc):/picolibc -w /picolibc -v $GITHUB_WORKSPACE/.ccache:/root/.ccache $IMAGE bash --login -c "${{ env.CCACHE_CMD }} --set-config=max_size=${{ env.CCACHE_SIZE }} && ${{ matrix.test }} ${{ matrix.meson_flags }} --buildtype minsize" 117 118 release-zephyr: 119 needs: cache-maker 120 runs-on: ubuntu-latest 121 strategy: 122 matrix: 123 meson_flags: [ 124 "", 125 126 # Tinystdio and math configurations, one with multithread disabled and with locale, original malloc and atexit/onexit code 127 "-Dio-float-exact=false -Dio-long-long=true -Dio-percent-b=true -Dio-long-double=true -Dnewlib-obsolete-math=false -Dwant-math-errno=true -Dnewlib-multithread=false -Dnewlib-retargetable-locking=false -Dnewlib-locale-info=true -Dnewlib-locale-info-extended=true -Dnewlib-mb=true -Dnewlib-iconv-external-ccs=true -Dnewlib-nano-malloc=false -Dpicoexit=false -Dprintf-small-ultoa=true", 128 "-Dformat-default=integer -Dfreestanding=true -Dposix-io=false -Dnewlib-obsolete-math=true -Dwant-math-errno=true -Dassert-verbose=false -Dfast-bufio=true", 129 130 # Original stdio, one with multithread disabled 131 "-Dtinystdio=false", 132 "-Dtinystdio=false -Dnewlib-io-float=true -Dio-long-long=true -Dio-long-double=true -Dnewlib-fvwrite-in-streamio=true -Dnewlib-multithread=false -Dnewlib-retargetable-locking=false", 133 ] 134 test: [ 135 "./.github/do-zephyr", 136 ] 137 steps: 138 - name: Clone picolibc 139 uses: actions/checkout@v4 140 with: 141 path: picolibc 142 143 - name: Restore the Docker Image 144 uses: actions/cache@v4 145 with: 146 path: ${{ env.IMAGE_FILE }} 147 key: ${{ env.IMAGE_FILE }}-${{ hashFiles( env.DOCKERFILE, env.PACKAGES_FILE, env.EXTRA_FILE ) }} 148 fail-on-cache-miss: true 149 150 - name: Load and Check the Docker Image 151 run: | 152 docker load -i $IMAGE_FILE 153 docker images -a $IMAGE 154 155 # The docker image contains ccache, but the ccache action uses the ccache 156 # outside docker for statistics, so install the same ccache version. 157 # Install in /usr/bin so the ccache action gets the expected environment. 158 - name: install ccache 159 if: matrix.test == './.github/do-zephyr' 160 run: | 161 wget -nv https://github.com/ccache/ccache/releases/download/v4.8.2/ccache-4.8.2-linux-x86_64.tar.xz 162 sudo tar xf ccache-4.8.2-linux-x86_64.tar.xz -C /usr/bin --strip-components=1 --no-same-owner ccache-4.8.2-linux-x86_64/ccache 163 rm -f ccache-*-linux-x86_64.tar.xz 164 165 # Key on job name and cache size to get separate caches for linux 166 # and zephyr. 167 - name: ccache 168 if: matrix.test == './.github/do-zephyr' 169 uses: hendrikmuhs/ccache-action@v1.2.11 170 with: 171 key: compilation-${{ runner.os }}-${{ github.job }}-${{ matrix.meson_flags }}-${{ env.CCACHE_SIZE }} 172 max-size: ${{ env.CCACHE_SIZE }} 173 174 - name: Release test 175 run: | 176 docker run -v $(readlink -f picolibc):/picolibc -w /picolibc -v $GITHUB_WORKSPACE/.ccache:/root/.ccache $IMAGE bash --login -c "${{ env.CCACHE_CMD }} --set-config=max_size=${{ env.CCACHE_SIZE }} && ${{ matrix.test }} ${{ matrix.meson_flags }} --buildtype release" 177 178