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 cmake-linux: 58 needs: cache-maker 59 runs-on: ubuntu-latest 60 strategy: 61 matrix: 62 cmake_flags: [ 63 "", 64 # optional configurations 65 "-D__IO_FLOAT=y -D_IO_FLOAT_EXACT=n -D_WANT_IO_LONG_LONG=y -D_MB_CAPABLE=y -D_WANT_IO_POS_ARGS=y -D__HAVE_LOCALE_INFO__=y -D__HAVE_LOCALE_INFO_EXTENDED__=y -D_WANT_MINIMAL_IO_LONG_LONG=y", 66 ] 67 test: [ 68 "./.github/do-cmake-linux -DCMAKE_BUILD_TYPE=RelWithDebInfo", 69 "./.github/do-cmake-linux -DCMAKE_BUILD_TYPE=MinSizeRel", 70 ] 71 steps: 72 - name: Clone picolibc 73 uses: actions/checkout@v4 74 with: 75 path: picolibc 76 77 - name: Restore the Docker Image 78 uses: actions/cache@v4 79 with: 80 path: ${{ env.IMAGE_FILE }} 81 key: ${{ env.IMAGE_FILE }}-${{ hashFiles( env.DOCKERFILE, env.PACKAGES_FILE, env.EXTRA_FILE ) }} 82 fail-on-cache-miss: true 83 84 - name: Load and Check the Docker Image 85 run: | 86 docker load -i $IMAGE_FILE 87 docker images -a $IMAGE 88 89 # The docker image contains ccache, but the ccache action uses the ccache 90 # outside docker for statistics, so install the same ccache version. 91 # Install in /usr/bin so the ccache action gets the expected environment. 92 - name: install ccache 93 if: matrix.test == './.github/do-zephyr' 94 run: | 95 wget -nv https://github.com/ccache/ccache/releases/download/v4.8.2/ccache-4.8.2-linux-x86_64.tar.xz 96 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 97 rm -f ccache-*-linux-x86_64.tar.xz 98 99 # Key on job name and cache size to get separate caches for linux 100 # and zephyr. 101 - name: ccache 102 if: matrix.test == './.github/do-zephyr' 103 uses: hendrikmuhs/ccache-action@v1.2.11 104 with: 105 key: compilation-${{ runner.os }}-${{ github.job }}-${{ matrix.meson_flags }}-${{ env.CCACHE_SIZE }} 106 max-size: ${{ env.CCACHE_SIZE }} 107 108 - name: CMake test 109 run: | 110 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.cmake_flags }}" 111 112 minsize-linux: 113 needs: cache-maker 114 runs-on: ubuntu-latest 115 strategy: 116 matrix: 117 meson_flags: [ 118 "", 119 120 # Tinystdio and math configurations, one with multithread disabled and with locale, original malloc and atexit/onexit code 121 "-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", 122 "-Dformat-default=integer -Dfreestanding=true -Dposix-io=false -Dnewlib-obsolete-math=true -Dwant-math-errno=true -Dassert-verbose=false -Dfast-bufio=true", 123 124 # Original stdio, one with multithread disabled 125 "-Dtinystdio=false", 126 "-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", 127 ] 128 test: [ 129 "./.github/do-linux", 130 ] 131 steps: 132 - name: Clone picolibc 133 uses: actions/checkout@v4 134 with: 135 path: picolibc 136 137 - name: Restore the Docker Image 138 uses: actions/cache@v4 139 with: 140 path: ${{ env.IMAGE_FILE }} 141 key: ${{ env.IMAGE_FILE }}-${{ hashFiles( env.DOCKERFILE, env.PACKAGES_FILE, env.EXTRA_FILE ) }} 142 fail-on-cache-miss: true 143 144 - name: Load and Check the Docker Image 145 run: | 146 docker load -i $IMAGE_FILE 147 docker images -a $IMAGE 148 149 # The docker image contains ccache, but the ccache action uses the ccache 150 # outside docker for statistics, so install the same ccache version. 151 # Install in /usr/bin so the ccache action gets the expected environment. 152 - name: install ccache 153 if: matrix.test == './.github/do-zephyr' 154 run: | 155 wget -nv https://github.com/ccache/ccache/releases/download/v4.8.2/ccache-4.8.2-linux-x86_64.tar.xz 156 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 157 rm -f ccache-*-linux-x86_64.tar.xz 158 159 # Key on job name and cache size to get separate caches for linux 160 # and zephyr. 161 - name: ccache 162 if: matrix.test == './.github/do-zephyr' 163 uses: hendrikmuhs/ccache-action@v1.2.11 164 with: 165 key: compilation-${{ runner.os }}-${{ github.job }}-${{ matrix.meson_flags }}-${{ env.CCACHE_SIZE }} 166 max-size: ${{ env.CCACHE_SIZE }} 167 168 - name: Minsize test 169 run: | 170 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" 171 172 release-linux: 173 needs: cache-maker 174 runs-on: ubuntu-latest 175 strategy: 176 matrix: 177 meson_flags: [ 178 "", 179 180 # Tinystdio and math configurations, one with multithread disabled and with locale, original malloc and atexit/onexit code 181 "-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", 182 "-Dformat-default=integer -Dfreestanding=true -Dposix-io=false -Dnewlib-obsolete-math=true -Dwant-math-errno=true -Dassert-verbose=false -Dfast-bufio=true", 183 184 # Original stdio, one with multithread disabled 185 "-Dtinystdio=false", 186 "-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", 187 ] 188 test: [ 189 "./.github/do-linux", 190 ] 191 steps: 192 - name: Clone picolibc 193 uses: actions/checkout@v4 194 with: 195 path: picolibc 196 197 - name: Restore the Docker Image 198 uses: actions/cache@v4 199 with: 200 path: ${{ env.IMAGE_FILE }} 201 key: ${{ env.IMAGE_FILE }}-${{ hashFiles( env.DOCKERFILE, env.PACKAGES_FILE, env.EXTRA_FILE ) }} 202 fail-on-cache-miss: true 203 204 - name: Load and Check the Docker Image 205 run: | 206 docker load -i $IMAGE_FILE 207 docker images -a $IMAGE 208 209 # The docker image contains ccache, but the ccache action uses the ccache 210 # outside docker for statistics, so install the same ccache version. 211 # Install in /usr/bin so the ccache action gets the expected environment. 212 - name: install ccache 213 if: matrix.test == './.github/do-zephyr' 214 run: | 215 wget -nv https://github.com/ccache/ccache/releases/download/v4.8.2/ccache-4.8.2-linux-x86_64.tar.xz 216 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 217 rm -f ccache-*-linux-x86_64.tar.xz 218 219 # Key on job name and cache size to get separate caches for linux 220 # and zephyr. 221 - name: ccache 222 if: matrix.test == './.github/do-zephyr' 223 uses: hendrikmuhs/ccache-action@v1.2.11 224 with: 225 key: compilation-${{ runner.os }}-${{ github.job }}-${{ matrix.meson_flags }}-${{ env.CCACHE_SIZE }} 226 max-size: ${{ env.CCACHE_SIZE }} 227 228 - name: Release test 229 run: | 230 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" 231 232