summaryrefslogtreecommitdiff
path: root/.github/workflows/check_misc.yml
blob: f194d007799d113304585066b04f99a455b1b625 (plain)
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Misc
on: [push, pull_request, merge_group]

concurrency:
  group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
  cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}

permissions:
  contents: read

jobs:
  checks:
    name: Miscellaneous checks

    permissions:
      contents: write # for Git to git push

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          token: ${{ (github.repository == 'ruby/ruby' && !startsWith(github.event_name, 'pull')) && secrets.MATZBOT_AUTO_UPDATE_TOKEN || secrets.GITHUB_TOKEN }}
          persist-credentials: false

      - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
        with:
          ruby-version: head

      - uses: ./.github/actions/setup/directories
        with:
          makeup: true
          # Skip overwriting MATZBOT_AUTO_UPDATE_TOKEN
          checkout: '' # false (ref: https://github.com/actions/runner/issues/2238)

      - name: Re-generate Makefiles
        run: |
          # config.status needs to run as a shell script
          { echo ':&&exit'; cat tool/prereq.status; } > config.status
          : # same as actions/setup/directories/action.yml
          for mk in Makefile GNUmakefile; do
            sed -f tool/prereq.status template/$mk.in > $mk
          done

      - name: Check for code styles
        run: |
          set -x
          ruby tool/auto-style.rb "$GITHUB_OLD_SHA" "$GITHUB_NEW_SHA"
        env:
          GITHUB_OLD_SHA: ${{ github.event.pull_request.base.sha }}
          GITHUB_NEW_SHA: ${{ github.event.pull_request.merge_commit_sha }}
        # Skip 'push' events because post_push.yml fixes them on push
        if: ${{ github.repository == 'ruby/ruby' && startsWith(github.event_name, 'pull') }}

      - name: Check if date in man pages is up-to-date
        run: |
          git fetch origin --depth=1 "${GITHUB_OLD_SHA}"
          git diff --exit-code --name-only "${GITHUB_OLD_SHA}" HEAD -- man ||
          make V=1 GIT=git BASERUBY=ruby update-man-date
          git diff --color --no-ext-diff --ignore-submodules --exit-code -- man
        env:
          GITHUB_OLD_SHA: ${{ github.event.pull_request.base.sha }}
        if: ${{ startsWith(github.event_name, 'pull') }}

      - name: Check for bash specific substitution in configure.ac
        run: |
          git grep -n '\${[A-Za-z_0-9]*/' -- configure.ac && exit 1 || :

      - name: Check for header macros
        run: |
          fail=
          for header in ruby/*.h; do
            git grep -l -F -e $header -e HAVE_`echo $header | tr a-z./ A-Z__` -- . > /dev/null && continue
            fail=1
            echo $header
          done
          exit $fail
        working-directory: include

      - id: now
        run: |
          date +"mon=%-m"%n"day=%-d" >> $GITHUB_OUTPUT
        env:
          TZ: Asia/Tokyo

      - id: deprecation
        run: |
          eval $(sed -n 's/^#define RUBY_API_VERSION_\(MAJOR\|MINOR\) /\1=/p' include/ruby/version.h)
          if git --no-pager grep --color -o 'rb_warn_deprecated_to_remove_at('$MAJOR'\.'$MINOR',.*' -- '*.c' >&2; then
              false
          else
              true
          fi
        continue-on-error: ${{ steps.now.outputs.mon < 12 }}

      - name: Check if to generate documents
        id: rdoc
        run: |
          set -- $(sed 's/#.*//;/^rdoc /!d' gems/bundled_gems)
          { echo version=$2; echo ref=$4; } >> $GITHUB_OUTPUT

      - name: Checkout rdoc
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          repository: ruby/rdoc
          ref: ${{ steps.rdoc.outputs.ref }}
          path: .bundle/gems/rdoc-${{ steps.rdoc.outputs.version }}
          persist-credentials: false
        if: ${{ steps.rdoc.outputs.ref != '' }}

      - name: Generate rdoc scripts
        run: |
          set -x
          gempath=$(ruby -e 'print Gem.user_dir, "/bin"')
          PATH=$gempath:$PATH
          gem install --user bundler
          bundle config --local path vendor/bundle
          bundle install --jobs 4
          bundle exec rake generate
        working-directory: .bundle/gems/rdoc-${{ steps.rdoc.outputs.version }}
        if: ${{ steps.rdoc.outputs.ref != '' }}

      - name: Core docs coverage
        run: |
          make XRUBY=ruby RDOC_DEPENDS= RBCONFIG=update-rbconfig rdoc-coverage

      - name: Generate docs
        id: docs
        run: |
          make XRUBY=ruby RDOC_DEPENDS= RBCONFIG=update-rbconfig HTMLOUT=html html
          echo htmlout=ruby-html-${GITHUB_SHA:0:10} >> $GITHUB_OUTPUT
        # Generate only when document commit/PR
        if: >-
          ${{false
          || contains(github.event.head_commit.message, '[ruby/rdoc]')
          || contains(github.event.head_commit.message, '[DOC]')
          || contains(github.event.pull_request.title, '[DOC]')
          || contains(github.event.pull_request.labels.*.name, 'Documentation')
          }}

      - name: Upload docs
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          path: html
          name: ${{ steps.docs.outputs.htmlout }}
        if: ${{ steps.docs.outcome == 'success' }}

      - uses: ./.github/actions/slack
        with:
          SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
        if: ${{ failure() }}