diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9e44ba6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,226 @@ +name: CI + +on: + # Trigger the workflow on push or pull requests. + push: + pull_request: + + +jobs: + get_commit_list: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get commit list + id: get_commit_list + run: | + git config core.abbrev 12; + ( \ + ( \ + git log --pretty="%h" --reverse ${{github.event.commits[0].id}}^...${{github.sha}} || \ + (printf "%s" ${{github.sha}} | head -c 12) \ + ) | awk '{ print "id" NR "=" $1 }' \ + ) > $GITHUB_OUTPUT; + echo "List of tested commits:" > $GITHUB_STEP_SUMMARY; + cat $GITHUB_OUTPUT >> $GITHUB_STEP_SUMMARY; + + outputs: + commit_list: ${{ toJson(steps.*.outputs.*) }} + + + build: + needs: get_commit_list + runs-on: ubuntu-24.04 + strategy: + fail-fast: false + matrix: + commit: ${{ fromJson(needs.get_commit_list.outputs.commit_list) }} + build_args: + # x86-64 gcc + - arch: x86_64 + cc_pkg: gcc-x86-64-linux-gnu + cc: x86_64-linux-gnu-gcc + sanitize: 0 + + # x86-64 gcc asan + - arch: x86_64 + cc_pkg: gcc-x86-64-linux-gnu + cc: x86_64-linux-gnu-gcc + sanitize: 1 + + # x86-64 clang asan + - arch: x86_64 + cc_pkg: clang + cc: clang + sanitize: 1 + + # x86-64 clang + - arch: x86_64 + cc_pkg: clang + cc: clang + sanitize: 0 + + # x86 (32-bit) gcc + - arch: i686 + cc_pkg: gcc-i686-linux-gnu + cc: i686-linux-gnu-gcc + sanitize: 0 + + # aarch64 gcc + - arch: aarch64 + cc_pkg: gcc-aarch64-linux-gnu + cc: aarch64-linux-gnu-gcc + sanitize: 0 + + # arm (32-bit) gcc + - arch: arm + cc_pkg: gcc-arm-linux-gnueabi + cc: arm-linux-gnueabi-gcc + sanitize: 0 + + # riscv64 + - arch: riscv64 + cc_pkg: gcc-riscv64-linux-gnu + cc: riscv64-linux-gnu-gcc + sanitize: 0 + + # powerpc64 + - arch: powerpc64 + cc_pkg: gcc-powerpc64-linux-gnu + cc: powerpc64-linux-gnu-gcc + sanitize: 0 + + # powerpc + - arch: powerpc + cc_pkg: gcc-powerpc-linux-gnu + cc: powerpc-linux-gnu-gcc + sanitize: 0 + + # alpha + - arch: alpha + cc_pkg: gcc-alpha-linux-gnu + cc: alpha-linux-gnu-gcc + sanitize: 0 + + # mips64 + - arch: mips64 + cc_pkg: gcc-mips64-linux-gnuabi64 + cc: mips64-linux-gnuabi64-gcc + sanitize: 0 + + # mips + - arch: mips + cc_pkg: gcc-mips-linux-gnu + cc: mips-linux-gnu-gcc + sanitize: 0 + + # hppa + - arch: hppa + cc_pkg: gcc-hppa-linux-gnu + cc: hppa-linux-gnu-gcc + sanitize: 0 + + env: + CC: ${{matrix.build_args.cc}} + SANITIZE: ${{matrix.build_args.sanitize}} + + steps: + - name: Checkout source + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Checkout commit + run: | + git checkout ${{ matrix.commit }}; + + - name: Install Compilers + run: | + sudo apt-get update -y; + sudo apt-get install -y ${{matrix.build_args.cc_pkg}}; + + - name: Display compiler versions + run: | + ${{matrix.build_args.cc}} --version; + + - name: Build + run: | + make clean; + make -j$(nproc) CC=${{matrix.build_args.cc}} SANITIZE=${{matrix.build_args.sanitize}}; + + - name: Test + run: | + make test || true; + + + alpine-musl-build: + needs: get_commit_list + runs-on: ubuntu-24.04 + strategy: + matrix: + commit: ${{ fromJson(needs.get_commit_list.outputs.commit_list) }} + + steps: + - name: Checkout source + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Checkout commit + run: | + git checkout ${{ matrix.commit }}; + + - name: Setup Alpine Environment + uses: jirutka/setup-alpine@v1 + with: + branch: v3.15 + + - name: Display Alpine version + shell: alpine.sh {0} + run: cat /etc/alpine-release; + + - name: Install build dependencies + shell: alpine.sh --root {0} + run: | + apk add --no-cache build-base musl-dev linux-headers; + + - name: Build + shell: alpine.sh {0} + run: | + make clean; + make -j$(nproc); + + - name: Test + shell: alpine.sh {0} + run: | + make test || true; + + + codespell: + needs: get_commit_list + runs-on: ubuntu-24.04 + strategy: + matrix: + commit: ${{ fromJson(needs.get_commit_list.outputs.commit_list) }} + + steps: + - name: Checkout source + uses: actions/checkout@v4 + + - name: Checkout commit + run: | + git checkout ${{ matrix.commit }}; + + - name: Install codespell + run: | + sudo apt-get update -y + sudo apt-get install -y codespell + + - name: Display codespell version + run: codespell --version + + - name: Execute codespell + run: codespell . \ No newline at end of file