compile.yml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. name: Compile & test
  2. # Run whenever we push to any branch other than [coverity-scan], or if we
  3. # manually trigger a workflow.
  4. on:
  5. push:
  6. branches:
  7. - '**'
  8. - '!coverity-scan'
  9. workflow_dispatch:
  10. env:
  11. # Shared variables amongst all projects / platforms / compilers.
  12. CFLAGS_ALL: -std=c99 -O2
  13. CFLAGS_CLANG_LIBCPERCIVA: -Wall -Wextra -Werror -Weverything
  14. -Wno-#warnings -Wno-pedantic -Wno-padded
  15. -Wno-format-nonliteral
  16. -Wno-disabled-macro-expansion
  17. -Wno-missing-noreturn -Wno-reserved-id-macro
  18. -Wno-unused-macros
  19. -Wno-documentation-unknown-command
  20. CFLAGS_GCC_LIBCPERCIVA: -Wall -Wextra -Werror -Wpedantic
  21. -pedantic-errors -Wno-clobbered
  22. # Variables for specific projects / platforms / compilers.
  23. LIBARCHIVE_OBJECTS: tar/tarsnap-bsdtar.o tar/tarsnap-getdate.o
  24. tar/tarsnap-read.o tar/tarsnap-subst.o
  25. tar/tarsnap-tree.o tar/tarsnap-util.o
  26. tar/tarsnap-write.o libarchive/libarchive.a
  27. CFLAGS_CLANG_PROJECT: -Wno-undef -Wno-implicit-fallthrough
  28. CFLAGS_GCC_PROJECT: -Wno-cpp
  29. # Needed for major() / minor() / makedev() thing.
  30. CFLAGS_LIBARCHIVE_GCC: -Wno-error
  31. CFLAGS_OSX: -Wno-poison-system-directories
  32. -Wno-deprecated-declarations
  33. LDFLAGS_OSX:
  34. jobs:
  35. Ubuntu:
  36. name: Ubuntu
  37. runs-on: ubuntu-20.04
  38. steps:
  39. - name: Update apt-get
  40. run: sudo apt-get update
  41. - name: Install software
  42. run: sudo apt-get install --no-install-recommends valgrind e2fslibs-dev
  43. autoconf-archive
  44. - name: Checkout code
  45. uses: actions/checkout@v4
  46. - name: autoreconf
  47. run:
  48. autoreconf -i
  49. - name: configure with clang
  50. env:
  51. CC: clang-10
  52. CFLAGS: ${{ env.CFLAGS_ALL }}
  53. run: ./configure
  54. - name: Compile libarchive with clang
  55. env:
  56. CC: clang-10
  57. # We need to use more permissive CFLAGS for libarchive code.
  58. CFLAGS: ${{ env.CFLAGS_ALL }}
  59. run: make ${{ env.LIBARCHIVE_OBJECTS }}
  60. - name: Compile with clang
  61. env:
  62. CC: clang-10
  63. CFLAGS: ${{ env.CFLAGS_ALL }}
  64. ${{ env.CFLAGS_CLANG_LIBCPERCIVA }}
  65. ${{ env.CFLAGS_CLANG_PROJECT }}
  66. # make(1) doesn't automatically override the CFLAGS macro set inside
  67. # Makefile with the environment variable.
  68. run: make CFLAGS="${{ env.CFLAGS }}"
  69. - name: Test clang binaries
  70. env:
  71. USE_VALGRIND: 1
  72. run: make test VERBOSE=1
  73. - name: Clean
  74. run: make clean
  75. - name: configure with gcc
  76. env:
  77. CC: gcc-10
  78. CFLAGS: ${{ env.CFLAGS_ALL }}
  79. run: ./configure
  80. - name: Compile libarchive with gcc
  81. env:
  82. CC: gcc-10
  83. # We need to use more permissive CFLAGS for libarchive code.
  84. CFLAGS: ${{ env.CFLAGS_ALL }}
  85. ${{ env.CFLAGS_LIBARCHIVE_GCC }}
  86. run: make ${{ env.LIBARCHIVE_OBJECTS }}
  87. - name: Compile with gcc
  88. env:
  89. CC: gcc-10
  90. CFLAGS: ${{ env.CFLAGS_ALL }}
  91. ${{ env.CFLAGS_GCC_LIBCPERCIVA }}
  92. ${{ env.CFLAGS_GCC_PROJECT }}
  93. # make(1) doesn't automatically override the CFLAGS macro set inside
  94. # Makefile with the environment variable.
  95. run: make CFLAGS="${{ env.CFLAGS }}"
  96. - name: Test gcc binaries
  97. env:
  98. USE_VALGRIND: 1
  99. run: make test VERBOSE=1
  100. - name: Check for untracked files
  101. run: test -z "$(git status --porcelain=v1)"
  102. macOS:
  103. name: macOS
  104. runs-on: macOS-12
  105. steps:
  106. - name: Checkout code
  107. uses: actions/checkout@v4
  108. - name: Install software
  109. run: brew install automake
  110. - name: autoreconf
  111. run: autoreconf -i
  112. - name: configure with clang
  113. env:
  114. CC: clang
  115. CFLAGS: ${{ env.CFLAGS_ALL }}
  116. ${{ env.CFLAGS_OSX }}
  117. LDFLAGS: ${{ env.LDFLAGS_OSX }}
  118. run: ./configure
  119. - name: Compile libarchive with clang
  120. env:
  121. CC: clang
  122. # We need to use more permissive CFLAGS for libarchive code.
  123. CFLAGS: ${{ env.CFLAGS_ALL }}
  124. run: make ${{ env.LIBARCHIVE_OBJECTS }}
  125. - name: Compile with clang
  126. env:
  127. CC: clang
  128. CFLAGS: ${{ env.CFLAGS_ALL }}
  129. ${{ env.CFLAGS_CLANG_LIBCPERCIVA }}
  130. ${{ env.CFLAGS_CLANG_PROJECT }}
  131. ${{ env.CFLAGS_OSX }}
  132. LDFLAGS: ${{ env.LDFLAGS_OSX }}
  133. # make(1) doesn't automatically override the CFLAGS macro set inside
  134. # Makefile with the environment variable.
  135. run: make CFLAGS="${{ env.CFLAGS }}"
  136. - name: Tests clang binaries
  137. run: make test VERBOSE=1