summaryrefslogtreecommitdiff
path: root/.github/workflows/ci.yml
blob: e9b73487c4de6f35bf5f25212201e7be2874e153 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: CI
on:
  push:
    branches: ['**']
    tags-ignore: ['**']
    paths-ignore: ['docs/**']
  pull_request:
    paths-ignore: ['docs/**']
  schedule:
  - cron: '0 2 * * *'
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
jobs:
  activate:
    if: |
      (github.event_name == 'schedule' && github.repository_owner == 'asciidoctor') ||
      (github.event_name != 'schedule' && !endsWith(github.event.head_commit.message, '[skip ci]'))
    runs-on: ubuntu-latest
    steps:
    - name: Proceed
      run: echo ok go
  build:
    needs: activate
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
        ruby: [jruby-9.3.7.0, '2.5', '2.7', '3.0', '3.1']
        asciimath-version: [~]
        pygments-version: ['~> 2.0']
        rouge-version: [~]
        exclude:
        # remove 3.1 on ubuntu-latest to mark as primary
        - os: ubuntu-latest
          ruby: '3.1'
        include:
        - os: ubuntu-latest
          ruby: truffleruby-21.1.0
        - os: ubuntu-latest
          ruby: jruby-9.1.17.0
          pygments-version: ~
        - os: windows-latest
          ruby: jruby-9.1.17.0
          pygments-version: ~
        - os: macos-latest
          ruby: '3.1'
        - os: ubuntu-latest
          ruby: '2.5'
          asciimath-version: '~> 1.0.0'
        - os: ubuntu-latest
          ruby: '2.5'
          pygments-version: '~> 1.2.0'
        - os: ubuntu-latest
          ruby: '2.5'
          rouge-version: '~> 2.0.0'
        - os: ubuntu-latest
          ruby: '3.1'
          primary: primary
    runs-on: ${{ matrix.os }}
    env:
      BUNDLE_WITHOUT: docs
      SOURCE_DATE_EPOCH: '1521504000'
      # work around `Permission denied - NUL' error when installing/using the bundler gem on JRuby for Windows
      JRUBY_OPTS: '-J-Djdk.io.File.enableADS=true'
    steps:
    - name: Checkout
      uses: actions/checkout@v2
    - name: Install prerequisites for Nokogiri (Linux)
      if: matrix.os == 'ubuntu-latest'
      run: sudo apt-get install libxslt1-dev
    - name: Configure Nokogiri installation (Linux, macOS)
      if: matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest'
      run: echo 'BUNDLE_BUILD__NOKOGIRI=--use-system-libraries' >> $GITHUB_ENV
    - name: Enable coverage
      if: matrix.primary
      run: echo 'COVERAGE=true' >> $GITHUB_ENV
    - name: Set AsciiMath version
      if: matrix.asciimath-version
      run: echo 'ASCIIMATH_VERSION=${{ matrix.asciimath-version }}' >> $GITHUB_ENV
    - name: Set Pygments version
      if: matrix.pygments-version
      run: echo 'PYGMENTS_VERSION=${{ matrix.pygments-version }}' >> $GITHUB_ENV
    - name: Set Rouge version
      if: matrix.rouge-version
      run: echo 'ROUGE_VERSION=${{ matrix.rouge-version }}' >> $GITHUB_ENV
    - name: Install Ruby (uses cached dependencies for non-scheduled build)
      uses: ruby/setup-ruby@v1
      with:
        ruby-version: ${{ matrix.ruby }}
        bundler: ${{ matrix.os == 'windows-latest' && matrix.ruby == '3.0' && '2.3' || 'default' }}
        bundler-cache: ${{ github.event_name != 'schedule' }}
    - name: Install dependencies (scheduled build only)
      if: github.event_name == 'schedule'
      run: |
        bundle config --local path vendor/bundle
        bundle --jobs 3 --retry 3
    - name: Run tests
      run: bundle exec ruby -w $(bundle exec ruby -e 'print File.join Gem.bindir, %q(rake)') test:all
    - name: Run linter
      if: matrix.primary
      run: bundle exec rake lint
    - name: Check default stylesheet
      if: matrix.primary
      run: |
        cd src/stylesheets
        npm i --silent --no-audit --no-audit --no-fund --no-package-lock --no-progress
        npm run lint
        npm run build
        cd -
        if [ -n "$(git diff --name-only -- data/stylesheets)" ]; then
          echo 'Detected the following uncommitted changes to the default stylesheet:'
          git diff
          exit 1
        fi
  build-dependents:
    name: build:dependents
    if: success() && github.event_name == 'push' && github.repository == 'asciidoctor/asciidoctor'
    needs: build
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v2
    - name: Install Ruby
      uses: ruby/setup-ruby@v1
      with:
        ruby-version: '3.1'
        bundler-cache: true
    - name: Build dependents
      env:
        GITHUB_API_TOKEN: ${{ secrets._GITHUB_API_TOKEN }}
      run: bundle exec rake build:dependents