ci_generate.nim 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. ##[
  2. avoid code duplication in CI pipelines.
  3. For now, this is only used for openbsd, but there is a lot of other code
  4. duplication that could be removed.
  5. ## usage
  6. edit this file as needed and then re-generate via:
  7. ```
  8. nim r tools/ci_generate.nim
  9. ```
  10. ]##
  11. import std/strformat
  12. proc genCIopenbsd(batch: int, num: int): string =
  13. result = fmt"""
  14. ## do not edit directly; auto-generated by `nim r tools/ci_generate.nim`
  15. image: openbsd/latest
  16. packages:
  17. - gmake
  18. - sqlite3
  19. - node
  20. - boehm-gc
  21. - pcre
  22. - sfml
  23. - sdl2
  24. - libffi
  25. sources:
  26. - https://github.com/nim-lang/Nim
  27. environment:
  28. NIM_TESTAMENT_BATCH: "{batch}_{num}"
  29. CC: /usr/bin/clang
  30. tasks:
  31. - setup: |
  32. cd Nim
  33. git clone --depth 1 -q https://github.com/nim-lang/csources.git
  34. gmake -C csources -j $(sysctl -n hw.ncpuonline)
  35. bin/nim c koch
  36. echo 'export PATH=$HOME/Nim/bin:$PATH' >> $HOME/.buildenv
  37. - test: |
  38. cd Nim
  39. if ! ./koch runCI; then
  40. nim c -r tools/ci_testresults.nim
  41. exit 1
  42. fi
  43. triggers:
  44. - action: email
  45. condition: failure
  46. to: Andreas Rumpf <rumpf_a@web.de>
  47. """
  48. proc main()=
  49. let num = 3
  50. # if you reduce this, make sure to remove files that shouldn't be generated,
  51. # or better, do the cleanup logic here e.g.: `rm .builds/openbsd_*`
  52. for i in 0..<num:
  53. let file = fmt".builds/openbsd_{i}.yml"
  54. let code = genCIopenbsd(i, num)
  55. writeFile(file, code)
  56. when isMainModule:
  57. main()