1name: Linux 2 3on: 4 pull_request: 5 push: 6 release: 7 types: published 8 9jobs: 10 build: 11 runs-on: [ubuntu-latest] 12 container: 13 image: centos:7 14 steps: 15 - uses: actions/checkout@v2 16 - uses: codespell-project/actions-codespell@master 17 with: 18 ignore_words_list: fo,wee 19 - name: Install dependencies 20 run: | 21 curl -L -O https://github.com/Kitware/CMake/releases/download/v3.16.4/cmake-3.16.4-Linux-x86_64.sh 22 chmod +x cmake-3.16.4-Linux-x86_64.sh 23 ./cmake-3.16.4-Linux-x86_64.sh --skip-license --prefix=/usr/local 24 curl -L -O https://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/7/x86_64/Packages/p/p7zip-16.02-20.el7.x86_64.rpm 25 curl -L -O https://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/7/x86_64/Packages/p/p7zip-plugins-16.02-20.el7.x86_64.rpm 26 rpm -U --quiet p7zip-16.02-20.el7.x86_64.rpm 27 rpm -U --quiet p7zip-plugins-16.02-20.el7.x86_64.rpm 28 yum install -y make gcc-c++ libasan clang-analyzer 29 30 - name: Build debug ninja 31 shell: bash 32 env: 33 CFLAGS: -fstack-protector-all -fsanitize=address 34 CXXFLAGS: -fstack-protector-all -fsanitize=address 35 run: | 36 scan-build -o scanlogs cmake -DCMAKE_BUILD_TYPE=Debug -B debug-build 37 scan-build -o scanlogs cmake --build debug-build --parallel --config Debug 38 39 - name: Test debug ninja 40 run: ./ninja_test 41 working-directory: debug-build 42 43 - name: Build release ninja 44 shell: bash 45 run: | 46 cmake -DCMAKE_BUILD_TYPE=Release -B release-build 47 cmake --build release-build --parallel --config Release 48 strip release-build/ninja 49 50 - name: Test release ninja 51 run: ./ninja_test 52 working-directory: release-build 53 54 - name: Create ninja archive 55 run: | 56 mkdir artifact 57 7z a artifact/ninja-linux.zip ./release-build/ninja 58 59 # Upload ninja binary archive as an artifact 60 - name: Upload artifact 61 uses: actions/upload-artifact@v3 62 with: 63 name: ninja-binary-archives 64 path: artifact 65 66 - name: Upload release asset 67 if: github.event.action == 'published' 68 uses: actions/upload-release-asset@v1 69 env: 70 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 71 with: 72 upload_url: ${{ github.event.release.upload_url }} 73 asset_path: ./artifact/ninja-linux.zip 74 asset_name: ninja-linux.zip 75 asset_content_type: application/zip 76 77 test: 78 runs-on: [ubuntu-latest] 79 container: 80 image: ubuntu:20.04 81 steps: 82 - uses: actions/checkout@v2 83 - name: Install dependencies 84 run: | 85 apt update 86 apt install -y python3-pytest ninja-build clang-tidy python3-pip clang libgtest-dev 87 pip3 install cmake==3.17.* 88 - name: Configure (GCC) 89 run: cmake -Bbuild-gcc -DCMAKE_BUILD_TYPE=Debug -G'Ninja Multi-Config' 90 91 - name: Build (GCC, Debug) 92 run: cmake --build build-gcc --config Debug 93 - name: Unit tests (GCC, Debug) 94 run: ./build-gcc/Debug/ninja_test 95 - name: Python tests (GCC, Debug) 96 run: pytest-3 --color=yes ../.. 97 working-directory: build-gcc/Debug 98 99 - name: Build (GCC, Release) 100 run: cmake --build build-gcc --config Release 101 - name: Unit tests (GCC, Release) 102 run: ./build-gcc/Release/ninja_test 103 - name: Python tests (GCC, Release) 104 run: pytest-3 --color=yes ../.. 105 working-directory: build-gcc/Release 106 107 - name: Configure (Clang) 108 run: CC=clang CXX=clang++ cmake -Bbuild-clang -DCMAKE_BUILD_TYPE=Debug -G'Ninja Multi-Config' -DCMAKE_EXPORT_COMPILE_COMMANDS=1 109 110 - name: Build (Clang, Debug) 111 run: cmake --build build-clang --config Debug 112 - name: Unit tests (Clang, Debug) 113 run: ./build-clang/Debug/ninja_test 114 - name: Python tests (Clang, Debug) 115 run: pytest-3 --color=yes ../.. 116 working-directory: build-clang/Debug 117 118 - name: Build (Clang, Release) 119 run: cmake --build build-clang --config Release 120 - name: Unit tests (Clang, Release) 121 run: ./build-clang/Release/ninja_test 122 - name: Python tests (Clang, Release) 123 run: pytest-3 --color=yes ../.. 124 working-directory: build-clang/Release 125 126 - name: clang-tidy 127 run: /usr/lib/llvm-10/share/clang/run-clang-tidy.py -header-filter=src 128 working-directory: build-clang 129 130 build-with-python: 131 runs-on: [ubuntu-latest] 132 container: 133 image: ${{ matrix.image }} 134 strategy: 135 matrix: 136 image: ['ubuntu:14.04', 'ubuntu:16.04', 'ubuntu:18.04'] 137 steps: 138 - uses: actions/checkout@v2 139 - name: Install dependencies 140 run: | 141 apt update 142 apt install -y g++ python3 143 - name: ${{ matrix.image }} 144 run: | 145 python3 configure.py --bootstrap 146 ./ninja all 147 python3 misc/ninja_syntax_test.py 148 ./misc/output_test.py 149 150 build-aarch64: 151 name: Build Linux ARM64 152 runs-on: [ubuntu-latest] 153 steps: 154 - uses: actions/checkout@v3 155 156 - name: Build 157 uses: uraimo/run-on-arch-action@v2 158 with: 159 arch: aarch64 160 distro: ubuntu18.04 161 githubToken: ${{ github.token }} 162 dockerRunArgs: | 163 --volume "${PWD}:/ninja" 164 install: | 165 apt-get update -q -y 166 apt-get install -q -y make gcc g++ libasan5 clang-tools curl p7zip-full file 167 run: | 168 set -x 169 cd /ninja 170 171 # INSTALL CMAKE 172 CMAKE_VERSION=3.23.4 173 curl -L -O https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-aarch64.sh 174 chmod +x cmake-${CMAKE_VERSION}-Linux-aarch64.sh 175 ./cmake-${CMAKE_VERSION}-Linux-aarch64.sh --skip-license --prefix=/usr/local 176 177 # BUILD 178 cmake -DCMAKE_BUILD_TYPE=Release -B release-build 179 cmake --build release-build --parallel --config Release 180 strip release-build/ninja 181 file release-build/ninja 182 183 # TEST 184 pushd release-build 185 ./ninja_test 186 popd 187 188 # CREATE ARCHIVE 189 mkdir artifact 190 7z a artifact/ninja-linux-aarch64.zip ./release-build/ninja 191 192 # Upload ninja binary archive as an artifact 193 - name: Upload artifact 194 uses: actions/upload-artifact@v3 195 with: 196 name: ninja-binary-archives 197 path: artifact 198 199 - name: Upload release asset 200 if: github.event.action == 'published' 201 uses: actions/upload-release-asset@v1 202 env: 203 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 204 with: 205 upload_url: ${{ github.event.release.upload_url }} 206 asset_path: ./artifact/ninja-linux-aarch64.zip 207 asset_name: ninja-linux-aarch64.zip 208 asset_content_type: application/zip 209