ci_docs.yml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. jobs:
  30. build:
  31. if: |
  32. !contains(format('{0} {1}', github.event.head_commit.message, github.event.pull_request.title), '[skip ci]')
  33. strategy:
  34. fail-fast: false
  35. matrix:
  36. target: [linux, windows, osx]
  37. include:
  38. - target: linux
  39. os: ubuntu-18.04
  40. - target: windows
  41. os: windows-2019
  42. - target: osx
  43. os: macos-10.15
  44. name: ${{ matrix.target }}
  45. runs-on: ${{ matrix.os }}
  46. steps:
  47. - name: 'Checkout'
  48. uses: actions/checkout@v2
  49. - name: 'Install build dependencies (macOS)'
  50. if: runner.os == 'macOS'
  51. run: brew install make
  52. - name: 'Install build dependencies (Windows)'
  53. if: runner.os == 'Windows'
  54. shell: bash
  55. run: |
  56. mkdir dist
  57. curl -L https://nim-lang.org/download/mingw64.7z -o dist/mingw64.7z
  58. curl -L https://nim-lang.org/download/dlls.zip -o dist/dlls.zip
  59. 7z x dist/mingw64.7z -odist
  60. 7z x dist/dlls.zip -obin
  61. echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}"
  62. - name: 'Add build binaries to PATH'
  63. shell: bash
  64. run: echo "${{ github.workspace }}/bin" >> "${GITHUB_PATH}"
  65. - name: 'Get current csources version'
  66. id: csources-version
  67. shell: bash
  68. run: |
  69. sha=$(git ls-remote https://github.com/nim-lang/csources master | cut -f 1)
  70. echo "::set-output name=sha::$sha"
  71. - name: 'Get prebuilt csources from cache'
  72. id: csources-cache
  73. uses: actions/cache@v1
  74. with:
  75. path: bin
  76. key: '${{ matrix.os }}-${{ steps.csources-version.outputs.sha }}'
  77. - name: 'Checkout csources'
  78. if: steps.csources-cache.outputs.cache-hit != 'true'
  79. uses: actions/checkout@v2
  80. with:
  81. repository: nim-lang/csources
  82. path: csources
  83. - name: 'Build 1-stage compiler from csources'
  84. shell: bash
  85. run: |
  86. ext=
  87. [[ '${{ runner.os }}' == 'Windows' ]] && ext=.exe
  88. if [[ ! -x bin/nim-csources$ext ]]; then
  89. ncpu=
  90. case '${{ runner.os }}' in
  91. 'Linux')
  92. ncpu=$(nproc)
  93. ;;
  94. 'macOS')
  95. ncpu=$(sysctl -n hw.ncpu)
  96. ;;
  97. 'Windows')
  98. ncpu=$NUMBER_OF_PROCESSORS
  99. ;;
  100. esac
  101. [[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
  102. make -C csources -j $ncpu CC=gcc
  103. cp bin/nim{,-csources}$ext
  104. else
  105. echo 'Cache hit, using prebuilt csources'
  106. cp bin/nim{-csources,}$ext
  107. fi
  108. - name: 'Build koch'
  109. shell: bash
  110. run: nim c koch
  111. - name: 'Build the real compiler'
  112. shell: bash
  113. run: ./koch boot -d:release
  114. - name: 'Clone fusion'
  115. shell: bash
  116. run: ./koch fusion
  117. - name: 'Build documentation'
  118. shell: bash
  119. run: ./koch doc --git.commit:devel
  120. - name: 'Publish documentation to Github Pages'
  121. if: |
  122. github.event_name == 'push' && github.ref == 'refs/heads/devel' &&
  123. matrix.target == 'linux'
  124. uses: crazy-max/ghaction-github-pages@v1
  125. with:
  126. build_dir: doc/html
  127. env:
  128. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}