|
| 1 | +name: CI |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + - dev |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + - dev |
| 11 | + tags: '*' |
| 12 | +jobs: |
| 13 | + test: |
| 14 | + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} |
| 15 | + runs-on: ${{ matrix.os }} |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + version: |
| 20 | + - '1.0' |
| 21 | + - '1' # automatically expands to the latest stable 1.x release of Julia. |
| 22 | + os: |
| 23 | + - ubuntu-latest |
| 24 | + arch: |
| 25 | + - x64 |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v2 |
| 28 | + - uses: julia-actions/setup-julia@v1 |
| 29 | + with: |
| 30 | + version: ${{ matrix.version }} |
| 31 | + arch: ${{ matrix.arch }} |
| 32 | + - uses: actions/cache@v1 |
| 33 | + env: |
| 34 | + cache-name: cache-artifacts |
| 35 | + with: |
| 36 | + path: ~/.julia/artifacts |
| 37 | + key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} |
| 38 | + restore-keys: | |
| 39 | + ${{ runner.os }}-test-${{ env.cache-name }}- |
| 40 | + ${{ runner.os }}-test- |
| 41 | + ${{ runner.os }}- |
| 42 | + - uses: julia-actions/julia-buildpkg@v1 |
| 43 | + - uses: julia-actions/julia-runtest@v1 |
| 44 | + env: |
| 45 | + JULIA_NUM_THREADS: 2 |
| 46 | + - uses: julia-actions/julia-processcoverage@v1 |
| 47 | + - uses: codecov/codecov-action@v1 |
| 48 | + with: |
| 49 | + file: lcov.info |
| 50 | + docs: |
| 51 | + name: Documentation |
| 52 | + runs-on: ubuntu-latest |
| 53 | + steps: |
| 54 | + - uses: actions/checkout@v2 |
| 55 | + - uses: julia-actions/setup-julia@v1 |
| 56 | + with: |
| 57 | + version: '1' |
| 58 | + - run: | |
| 59 | + julia -e ' |
| 60 | + function set_environment_variable(name::AbstractString, value::AbstractString) |
| 61 | + github_env = ENV["GITHUB_ENV"] |
| 62 | + touch(github_env) |
| 63 | + open(github_env, "a") do io |
| 64 | + println(io, "$(name)=$(value)") |
| 65 | + end |
| 66 | + end |
| 67 | + event_name = "${{ github.event_name }}" |
| 68 | + if event_name == "pull_request" |
| 69 | + base_ref = "${{ github.base_ref }}" |
| 70 | + head_ref = "${{ github.head_ref }}" |
| 71 | + base_repository = "${{ github.repository }}" |
| 72 | + head_repository = "${{ github.event.pull_request.head.repo.full_name }}" |
| 73 | + build_docs = (base_ref == "master") && (head_ref == "dev") && (base_repository == head_repository) |
| 74 | + elseif event_name == "push" |
| 75 | + ref = "${{ github.ref }}" |
| 76 | + build_docs = (ref == "refs/heads/master") || (startswith(ref, "refs/tags/")) |
| 77 | + elseif event_name == "schedule" |
| 78 | + build_docs = ref == "refs/heads/master" |
| 79 | + elseif event_name == "workflow_dispatch" |
| 80 | + build_docs = ref == "refs/heads/master" |
| 81 | + else |
| 82 | + build_docs = false |
| 83 | + end |
| 84 | + if build_docs |
| 85 | + @info("We will build the docs") |
| 86 | + set_environment_variable("BUILD_DOCS", "true") |
| 87 | + else |
| 88 | + @info("We will NOT build the docs") |
| 89 | + set_environment_variable("BUILD_DOCS", "false") |
| 90 | + end' |
| 91 | + - run: | |
| 92 | + julia --project=docs -e ' |
| 93 | + if ENV["BUILD_DOCS"] == "true" |
| 94 | + using Pkg |
| 95 | + Pkg.develop(PackageSpec(path=pwd())) |
| 96 | + Pkg.instantiate() |
| 97 | + end' |
| 98 | + - run: | |
| 99 | + julia --project=docs -e ' |
| 100 | + if ENV["BUILD_DOCS"] == "true" |
| 101 | + using Documenter: doctest |
| 102 | + using MLJBase |
| 103 | + @info "attempting to run the doctests" |
| 104 | + doctest(MLJBase) |
| 105 | + else |
| 106 | + @info "skipping the doctests" |
| 107 | + end' |
| 108 | + - run: julia --project=docs -e ' |
| 109 | + if ENV["BUILD_DOCS"] == "true" |
| 110 | + @info "attempting to build the docs" |
| 111 | + run(`julia --project=docs docs/make.jl`) |
| 112 | + @info "successfully built the docs" |
| 113 | + else |
| 114 | + @info "skipping the docs build" |
| 115 | + end' |
| 116 | + env: |
| 117 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 118 | + DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} |
0 commit comments