|
| 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 | + |
| 31 | +jobs: |
| 32 | + build: |
| 33 | + if: | |
| 34 | + !contains(format('{0} {1}', github.event.head_commit.message, 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 | + |
| 47 | + name: ${{ matrix.target }} |
| 48 | + runs-on: ${{ matrix.os }} |
| 49 | + |
| 50 | + steps: |
| 51 | + - name: 'Checkout' |
| 52 | + uses: actions/checkout@v2 |
| 53 | + |
| 54 | + - name: 'Install build dependencies (macOS)' |
| 55 | + if: runner.os == 'macOS' |
| 56 | + run: brew install make |
| 57 | + |
| 58 | + - name: 'Install build dependencies (Windows)' |
| 59 | + if: runner.os == 'Windows' |
| 60 | + shell: bash |
| 61 | + run: | |
| 62 | + mkdir dist |
| 63 | + curl -L https://nim-lang.org/download/mingw64.7z -o dist/mingw64.7z |
| 64 | + curl -L https://nim-lang.org/download/dlls.zip -o dist/dlls.zip |
| 65 | + 7z x dist/mingw64.7z -odist |
| 66 | + 7z x dist/dlls.zip -obin |
| 67 | + echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}" |
| 68 | +
|
| 69 | + - name: 'Add build binaries to PATH' |
| 70 | + shell: bash |
| 71 | + run: echo "${{ github.workspace }}/bin" >> "${GITHUB_PATH}" |
| 72 | + |
| 73 | + - name: 'Get current csources version' |
| 74 | + id: csources-version |
| 75 | + shell: bash |
| 76 | + run: | |
| 77 | + sha=$(git ls-remote https://github.com/nim-lang/csources master | cut -f 1) |
| 78 | + echo "::set-output name=sha::$sha" |
| 79 | +
|
| 80 | + - name: 'Get prebuilt csources from cache' |
| 81 | + id: csources-cache |
| 82 | + uses: actions/cache@v1 |
| 83 | + with: |
| 84 | + path: bin |
| 85 | + key: '${{ matrix.os }}-${{ steps.csources-version.outputs.sha }}' |
| 86 | + |
| 87 | + - name: 'Checkout csources' |
| 88 | + if: steps.csources-cache.outputs.cache-hit != 'true' |
| 89 | + uses: actions/checkout@v2 |
| 90 | + with: |
| 91 | + repository: nim-lang/csources |
| 92 | + path: csources |
| 93 | + |
| 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 | +
|
| 114 | + make -C csources -j $ncpu CC=gcc |
| 115 | + cp bin/nim{,-csources}$ext |
| 116 | + else |
| 117 | + echo 'Cache hit, using prebuilt csources' |
| 118 | + cp bin/nim{-csources,}$ext |
| 119 | + fi |
| 120 | +
|
| 121 | + - name: 'Build koch' |
| 122 | + shell: bash |
| 123 | + run: nim c koch |
| 124 | + |
| 125 | + - name: 'Build the real compiler' |
| 126 | + shell: bash |
| 127 | + run: ./koch boot -d:release |
| 128 | + |
| 129 | + - name: 'Build documentation' |
| 130 | + shell: bash |
| 131 | + run: ./koch doc --git.commit:devel |
| 132 | + |
| 133 | + - name: 'Publish documentation to Github Pages' |
| 134 | + if: | |
| 135 | + github.event_name == 'push' && github.ref == 'refs/heads/devel' && |
| 136 | + matrix.target == 'linux' |
| 137 | + uses: crazy-max/ghaction-github-pages@v1 |
| 138 | + with: |
| 139 | + build_dir: doc/html |
| 140 | + env: |
| 141 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments