ci_docs.yml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. name: Nim Docs CI
  2. on:
  3. push:
  4. paths:
  5. - 'compiler/docgen.nim'
  6. - 'compiler/renderverbatim.nim'
  7. - 'config/nimdoc.cfg'
  8. - 'doc/**.rst'
  9. - 'doc/nimdoc.css'
  10. - 'lib/**.nim'
  11. - 'nimdoc/testproject/expected/testproject.html'
  12. - 'tools/dochack/dochack.nim'
  13. - 'tools/kochdocs.nim'
  14. - '.github/workflows/ci_docs.yml'
  15. - 'koch.nim'
  16. pull_request:
  17. # Run only on changes on these files.
  18. paths:
  19. - 'compiler/docgen.nim'
  20. - 'compiler/renderverbatim.nim'
  21. - 'config/nimdoc.cfg'
  22. - 'doc/**.rst'
  23. - 'doc/nimdoc.css'
  24. - 'lib/**.nim'
  25. - 'nimdoc/testproject/expected/testproject.html'
  26. - 'tools/dochack/dochack.nim'
  27. - 'tools/kochdocs.nim'
  28. - '.github/workflows/ci_docs.yml'
  29. - 'koch.nim'
  30. jobs:
  31. build:
  32. # see D20210329T004830
  33. if: |
  34. !contains(format('{0}', github.event.pull_request.title), '[skip ci]')
  35. strategy:
  36. fail-fast: false
  37. matrix:
  38. target: [linux, windows, osx]
  39. include:
  40. - target: linux
  41. os: ubuntu-18.04
  42. - target: windows
  43. os: windows-2019
  44. - target: osx
  45. os: macos-10.15
  46. name: ${{ matrix.target }}
  47. runs-on: ${{ matrix.os }}
  48. steps:
  49. - name: 'Checkout'
  50. uses: actions/checkout@v2
  51. with:
  52. fetch-depth: 2
  53. - name: 'Check whether to skip CI'
  54. shell: bash
  55. run: |
  56. # see D20210329T004830
  57. commitMsg=$(git log --no-merges -1 --pretty=format:"%s")
  58. echo commitMsg: $commitMsg
  59. echo $commitMsg | grep -v '\[skip ci\]'
  60. - name: 'Install build dependencies (macOS)'
  61. if: runner.os == 'macOS'
  62. run: brew install make
  63. - name: 'Install build dependencies (Windows)'
  64. if: runner.os == 'Windows'
  65. shell: bash
  66. run: |
  67. mkdir dist
  68. curl -L https://nim-lang.org/download/mingw64.7z -o dist/mingw64.7z
  69. curl -L https://nim-lang.org/download/dlls.zip -o dist/dlls.zip
  70. 7z x dist/mingw64.7z -odist
  71. 7z x dist/dlls.zip -obin
  72. echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}"
  73. - name: 'Add build binaries to PATH'
  74. shell: bash
  75. run: echo "${{ github.workspace }}/bin" >> "${GITHUB_PATH}"
  76. - name: 'Get current csources version'
  77. id: csources-version
  78. shell: bash
  79. run: |
  80. sha=$(git ls-remote https://github.com/nim-lang/csources master | cut -f 1)
  81. echo "::set-output name=sha::$sha"
  82. - name: 'Get prebuilt csources from cache'
  83. id: csources-cache
  84. uses: actions/cache@v1
  85. with:
  86. path: bin
  87. key: '${{ matrix.os }}-${{ steps.csources-version.outputs.sha }}'
  88. - name: 'Checkout csources'
  89. if: steps.csources-cache.outputs.cache-hit != 'true'
  90. uses: actions/checkout@v2
  91. with:
  92. repository: nim-lang/csources
  93. path: csources
  94. - name: 'Build 1-stage compiler from csources'
  95. shell: bash
  96. run: |
  97. ext=
  98. [[ '${{ runner.os }}' == 'Windows' ]] && ext=.exe
  99. if [[ ! -x bin/nim-csources$ext ]]; then
  100. ncpu=
  101. case '${{ runner.os }}' in
  102. 'Linux')
  103. ncpu=$(nproc)
  104. ;;
  105. 'macOS')
  106. ncpu=$(sysctl -n hw.ncpu)
  107. ;;
  108. 'Windows')
  109. ncpu=$NUMBER_OF_PROCESSORS
  110. ;;
  111. esac
  112. [[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
  113. make -C csources -j $ncpu CC=gcc
  114. cp bin/nim{,-csources}$ext
  115. else
  116. echo 'Cache hit, using prebuilt csources'
  117. cp bin/nim{-csources,}$ext
  118. fi
  119. - name: 'Build koch'
  120. shell: bash
  121. run: nim c koch
  122. - name: 'Build the real compiler'
  123. shell: bash
  124. run: ./koch boot -d:release
  125. - name: 'Build documentation'
  126. shell: bash
  127. run: ./koch doc --git.commit:devel
  128. - name: 'Publish documentation to Github Pages'
  129. if: |
  130. github.event_name == 'push' && github.ref == 'refs/heads/devel' &&
  131. matrix.target == 'linux'
  132. uses: crazy-max/ghaction-github-pages@v1
  133. with:
  134. build_dir: doc/html
  135. env:
  136. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}