rbs 4.0.3 → 4.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +37 -0
  3. data/.github/dependabot.yml +1 -1
  4. data/.github/workflows/bundle-update.yml +2 -2
  5. data/.github/workflows/c-check.yml +14 -6
  6. data/.github/workflows/comments.yml +2 -2
  7. data/.github/workflows/dependabot.yml +2 -2
  8. data/.github/workflows/jruby.yml +74 -0
  9. data/.github/workflows/release-gems.yml +235 -0
  10. data/.github/workflows/ruby.yml +43 -3
  11. data/.github/workflows/rust.yml +13 -10
  12. data/.github/workflows/truffleruby.yml +54 -0
  13. data/.github/workflows/typecheck.yml +5 -2
  14. data/.github/workflows/wasm.yml +55 -0
  15. data/.github/workflows/windows.yml +5 -2
  16. data/.gitignore +8 -0
  17. data/CHANGELOG.md +113 -0
  18. data/Dockerfile.jruby +53 -0
  19. data/README.md +4 -4
  20. data/Rakefile +512 -82
  21. data/Steepfile +9 -0
  22. data/config.yml +26 -0
  23. data/core/array.rbs +243 -180
  24. data/core/builtin.rbs +7 -6
  25. data/core/class.rbs +5 -3
  26. data/core/enumerable.rbs +109 -109
  27. data/core/enumerator/product.rbs +5 -5
  28. data/core/enumerator.rbs +28 -28
  29. data/core/file.rbs +24 -1018
  30. data/core/file_constants.rbs +463 -0
  31. data/core/file_stat.rbs +534 -0
  32. data/core/float.rbs +0 -24
  33. data/core/hash.rbs +117 -101
  34. data/core/integer.rbs +21 -58
  35. data/core/io.rbs +25 -7
  36. data/core/kernel.rbs +26 -11
  37. data/core/match_data.rbs +1 -1
  38. data/core/module.rbs +88 -74
  39. data/core/numeric.rbs +3 -0
  40. data/core/object_space/weak_key_map.rbs +7 -7
  41. data/core/pathname.rbs +0 -10
  42. data/core/ractor.rbs +0 -10
  43. data/core/range.rbs +23 -23
  44. data/core/rbs/ops.rbs +154 -0
  45. data/core/rbs/unnamed/argf.rbs +3 -3
  46. data/core/ruby_vm.rbs +40 -0
  47. data/core/rubygems/errors.rbs +4 -1
  48. data/core/rubygems/requirement.rbs +0 -10
  49. data/core/rubygems/rubygems.rbs +4 -1
  50. data/core/rubygems/specification.rbs +8 -0
  51. data/core/rubygems/version.rbs +0 -160
  52. data/core/set.rbs +3 -3
  53. data/core/struct.rbs +16 -16
  54. data/core/thread.rbs +9 -14
  55. data/docs/CONTRIBUTING.md +2 -1
  56. data/docs/inline.md +65 -7
  57. data/docs/rbs_by_example.md +20 -20
  58. data/docs/release.md +247 -0
  59. data/docs/syntax.md +2 -2
  60. data/docs/wasm_serialization.md +80 -0
  61. data/ext/rbs_extension/ast_translation.c +1298 -956
  62. data/ext/rbs_extension/ast_translation.h +4 -0
  63. data/ext/rbs_extension/class_constants.c +2 -0
  64. data/ext/rbs_extension/class_constants.h +1 -0
  65. data/ext/rbs_extension/extconf.rb +1 -0
  66. data/ext/rbs_extension/legacy_location.c +11 -6
  67. data/ext/rbs_extension/main.c +139 -4
  68. data/include/rbs/ast.h +323 -298
  69. data/include/rbs/defines.h +18 -0
  70. data/include/rbs/lexer.h +1 -0
  71. data/include/rbs/serialize.h +39 -0
  72. data/lib/rbs/annotate/rdoc_annotator.rb +27 -31
  73. data/lib/rbs/ast/ruby/annotations.rb +42 -0
  74. data/lib/rbs/ast/ruby/comment_block.rb +6 -4
  75. data/lib/rbs/ast/ruby/declarations.rb +11 -1
  76. data/lib/rbs/ast/ruby/helpers/location_helper.rb +1 -1
  77. data/lib/rbs/ast/ruby/members.rb +40 -1
  78. data/lib/rbs/buffer.rb +48 -11
  79. data/lib/rbs/cli.rb +3 -5
  80. data/lib/rbs/collection/config/lockfile_generator.rb +14 -1
  81. data/lib/rbs/collection/sources/git.rb +6 -0
  82. data/lib/rbs/definition_builder/method_builder.rb +12 -6
  83. data/lib/rbs/environment.rb +10 -3
  84. data/lib/rbs/inline_parser.rb +54 -28
  85. data/lib/rbs/namespace.rb +47 -11
  86. data/lib/rbs/parser_aux.rb +4 -2
  87. data/lib/rbs/prototype/rbi.rb +193 -25
  88. data/lib/rbs/prototype/runtime.rb +2 -0
  89. data/lib/rbs/resolver/type_name_resolver.rb +12 -14
  90. data/lib/rbs/rewriter.rb +70 -0
  91. data/lib/rbs/test/type_check.rb +6 -1
  92. data/lib/rbs/type_name.rb +33 -13
  93. data/lib/rbs/unit_test/type_assertions.rb +14 -5
  94. data/lib/rbs/version.rb +1 -1
  95. data/lib/rbs/wasm/deserializer.rb +213 -0
  96. data/lib/rbs/wasm/location.rb +61 -0
  97. data/lib/rbs/wasm/parser.rb +137 -0
  98. data/lib/rbs/wasm/runtime.rb +196 -0
  99. data/lib/rbs/wasm/serialization_schema.rb +110 -0
  100. data/lib/rbs.rb +14 -2
  101. data/lib/rbs_jars.rb +39 -0
  102. data/lib/rdoc_plugin/parser.rb +5 -0
  103. data/rbs.gemspec +32 -2
  104. data/sig/annotate/rdoc_annotater.rbs +12 -9
  105. data/sig/ast/ruby/annotations.rbs +49 -0
  106. data/sig/ast/ruby/members.rbs +21 -1
  107. data/sig/buffer.rbs +19 -1
  108. data/sig/collection/config/lockfile_generator.rbs +2 -0
  109. data/sig/inline_parser.rbs +2 -0
  110. data/sig/manifest.yaml +0 -1
  111. data/sig/namespace.rbs +20 -0
  112. data/sig/parser.rbs +10 -0
  113. data/sig/prototype/rbi.rbs +33 -4
  114. data/sig/resolver/type_name_resolver.rbs +2 -4
  115. data/sig/rewriter.rbs +45 -0
  116. data/sig/typename.rbs +15 -0
  117. data/sig/unit_test/type_assertions.rbs +6 -2
  118. data/sig/wasm/deserializer.rbs +66 -0
  119. data/sig/wasm/serialization_schema.rbs +13 -0
  120. data/src/ast.c +186 -162
  121. data/src/lexer.c +220 -193
  122. data/src/lexer.re +2 -1
  123. data/src/lexstate.c +10 -1
  124. data/src/parser.c +61 -8
  125. data/src/serialize.c +958 -0
  126. data/src/util/rbs_allocator.c +14 -8
  127. data/stdlib/abbrev/0/array.rbs +1 -1
  128. data/stdlib/csv/0/csv.rbs +5 -5
  129. data/stdlib/delegate/0/delegator.rbs +2 -1
  130. data/stdlib/digest/0/digest.rbs +11 -5
  131. data/stdlib/erb/0/erb.rbs +1 -1
  132. data/stdlib/etc/0/etc.rbs +18 -4
  133. data/stdlib/fileutils/0/fileutils.rbs +21 -21
  134. data/stdlib/ipaddr/0/ipaddr.rbs +0 -5
  135. data/stdlib/json/0/json.rbs +6 -6
  136. data/stdlib/monitor/0/monitor.rbs +2 -2
  137. data/stdlib/openssl/0/openssl.rbs +46 -40
  138. data/stdlib/resolv/0/resolv.rbs +1 -1
  139. data/stdlib/shellwords/0/shellwords.rbs +1 -1
  140. data/stdlib/stringio/0/stringio.rbs +32 -10
  141. data/stdlib/strscan/0/string_scanner.rbs +74 -55
  142. data/stdlib/tempfile/0/manifest.yaml +3 -0
  143. data/stdlib/timeout/0/timeout.rbs +0 -5
  144. data/stdlib/tsort/0/cyclic.rbs +1 -1
  145. data/stdlib/tsort/0/interfaces.rbs +8 -8
  146. data/stdlib/tsort/0/tsort.rbs +9 -9
  147. data/stdlib/uri/0/generic.rbs +0 -5
  148. data/stdlib/zlib/0/gzip_reader.rbs +2 -2
  149. data/stdlib/zlib/0/zstream.rbs +0 -1
  150. data/wasm/README.md +93 -0
  151. data/wasm/rbs_wasm.c +423 -0
  152. metadata +29 -6
  153. data/.github/workflows/milestone.yml +0 -80
  154. data/.vscode/extensions.json +0 -5
  155. data/.vscode/settings.json +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 77f310d0293781c4da3d3835ee34be5b310dc4aace7b75db580060432f5dd10c
4
- data.tar.gz: 8d982db360beced794afa05c156c40db8b368f7b2d0b0180ad61434d3c1eb0a9
3
+ metadata.gz: f90000891f13d57d27beb58a5176f5ff595e58628c51982dc18d985796bbb90d
4
+ data.tar.gz: 7f70e0544fa9c1b1312f1d4f0da5da4fa448bb651ced22f92bc8a6332507d501
5
5
  SHA512:
6
- metadata.gz: 87d0a52295c6167fb791c2ff843dee5a9b7c1d4cc9d13fe5ccf8c12abcc7ed507497021e691dd0cd1a134ff886c9ba29461f03f2a26fc3402af1c78bc36ec62f
7
- data.tar.gz: 40381f1988f06a3262de9367042ad0e04864f7c9f0a1556f30dc01003874db8018a77b10c613e090993738d3787861ccb84417631a4cc57c3998ca99c831eb8b
6
+ metadata.gz: 5b69502540c88356e2a22e89fe9931fe873421510b64004e7aec332cdb3393a0e75b72cdab2462f020efd9f3bd8b7d5b18b48b53b6ec133c09823c8c518e4536
7
+ data.tar.gz: 4598739801a2982e9517e34f11d64ab367a6cf70346866f8937fc44cf7496d4fc099b64510d966fc01c007421e63b07c5de59f17a33fa4140af0f5aa3f0a9193
data/.dockerignore ADDED
@@ -0,0 +1,37 @@
1
+ # Keep the build context small. .git is intentionally NOT ignored: rbs.gemspec
2
+ # builds its file list with `git ls-files`.
3
+ #
4
+ # Safe to ignore here: untracked/generated paths, and tracked paths the gemspec
5
+ # already rejects (so `gem build` does not expect them on disk). Do NOT ignore a
6
+ # tracked path the gemspec ships — `gem build` would fail with "... are not
7
+ # files". .vscode/ and benchmark/ are tracked but rejected by the gemspec.
8
+ .vscode/
9
+ benchmark/
10
+
11
+ # Editor / tooling / worktree copies (untracked; each is a full repo clone)
12
+ .claude/
13
+ trees/
14
+ .devcontainer/
15
+ .idea/
16
+ .ruby-lsp/
17
+ .yardoc/
18
+ doc/
19
+ datasets/
20
+ tmp/
21
+
22
+ # Build artifact — rebuilt inside the image by `rake wasm:jruby_setup`
23
+ lib/rbs/wasm/*.wasm
24
+ *.gem
25
+ ext/**/*.o
26
+ ext/**/*.so
27
+ ext/**/*.bundle
28
+ *.log
29
+
30
+ # Local scratch / experiment files
31
+ flamegraph.html
32
+ gc.html
33
+ foo.rbs
34
+ sorted.json
35
+ string.json
36
+ Gemfile-*
37
+ gemfiles/
@@ -21,4 +21,4 @@ updates:
21
21
  schedule:
22
22
  interval: 'weekly'
23
23
  labels:
24
- - 'no-milestone'
24
+ - 'skip-changelog'
@@ -11,7 +11,7 @@ jobs:
11
11
 
12
12
  steps:
13
13
  - name: Checkout repository
14
- uses: actions/checkout@v6
14
+ uses: actions/checkout@v7
15
15
 
16
16
  - name: Set up Ruby
17
17
  uses: ruby/setup-ruby@v1
@@ -58,6 +58,6 @@ jobs:
58
58
  --body "Automated weekly bundle update" \
59
59
  --head "$(git rev-parse --abbrev-ref HEAD)" \
60
60
  --base "${{ github.event.repository.default_branch }}" \
61
- --label "no-milestone"
61
+ --label "skip-changelog"
62
62
 
63
63
  gh pr merge --auto --merge "$(git rev-parse --abbrev-ref HEAD)"
@@ -7,11 +7,14 @@ on:
7
7
  pull_request: {}
8
8
  merge_group: {}
9
9
 
10
+ permissions:
11
+ contents: read
12
+
10
13
  jobs:
11
14
  format-check:
12
15
  runs-on: ubuntu-latest
13
16
  steps:
14
- - uses: actions/checkout@v6
17
+ - uses: actions/checkout@v7
15
18
  - uses: ruby/setup-ruby@v1
16
19
  with:
17
20
  ruby-version: "4.0"
@@ -24,8 +27,13 @@ jobs:
24
27
  sudo apt-get install -y libdb-dev curl autoconf automake m4 libtool
25
28
  - name: Install clang-format from LLVM
26
29
  run: |
27
- wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
28
- sudo apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-20 main"
30
+ # The codename must match the `runs-on` image: `ubuntu-latest` is 24.04 (noble).
31
+ wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key \
32
+ | sudo gpg --dearmor -o /usr/share/keyrings/llvm-archive-keyring.gpg
33
+ # Written directly rather than through `apt-add-repository`, which cannot
34
+ # parse `[signed-by=...]` inside a one-line `deb` shortcut.
35
+ echo "deb [signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/noble/ llvm-toolchain-noble-20 main" \
36
+ | sudo tee /etc/apt/sources.list.d/llvm.list
29
37
  sudo apt-get update
30
38
  sudo apt-get install -y clang-format-20
31
39
  sudo ln -sf /usr/bin/clang-format-20 /usr/local/bin/clang-format
@@ -35,9 +43,9 @@ jobs:
35
43
  - name: Install Re2c
36
44
  run: |
37
45
  cd /tmp
38
- curl -L https://github.com/skvadrik/re2c/archive/refs/tags/4.3.tar.gz > re2c-4.3.tar.gz
39
- tar xf re2c-4.3.tar.gz
40
- cd re2c-4.3
46
+ curl -L https://github.com/skvadrik/re2c/archive/refs/tags/4.5.1.tar.gz > re2c-4.5.1.tar.gz
47
+ tar xf re2c-4.5.1.tar.gz
48
+ cd re2c-4.5.1
41
49
  cmake --preset=linux-gcc-release-ootree-skeleton-fast
42
50
  cmake --build --preset=linux-gcc-release-ootree-skeleton-fast --parallel="$(nproc)"
43
51
  sudo ln -sf "$(pwd)"/.build/linux-gcc-release-ootree-skeleton-fast/re2c /usr/local/bin/re2c
@@ -13,10 +13,10 @@ jobs:
13
13
  # env:
14
14
  # RUBY_COMMIT: v4.0.0-preview2
15
15
  steps:
16
- - uses: actions/checkout@v6
16
+ - uses: actions/checkout@v7
17
17
  - uses: ruby/setup-ruby@v1
18
18
  with:
19
- ruby-version: "4.0.1"
19
+ ruby-version: "4.0.6"
20
20
  bundler: none
21
21
  - name: Install dependencies
22
22
  run: |
@@ -14,10 +14,10 @@ jobs:
14
14
  if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
15
15
  steps:
16
16
  - name: Dependabot metadata
17
- uses: dependabot/fetch-metadata@ffa630c65fa7e0ecfa0625b5ceda64399aea1b36 # v3.0.0
17
+ uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0
18
18
  id: metadata
19
19
  - name: Checkout repository
20
- uses: actions/checkout@v6
20
+ uses: actions/checkout@v7
21
21
  with:
22
22
  fetch-depth: 0
23
23
  - name: Abort if blocker files are changed
@@ -0,0 +1,74 @@
1
+ name: JRuby
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ paths:
9
+ - ".github/workflows/jruby.yml"
10
+ - "include/**"
11
+ - "src/**"
12
+ - "wasm/**"
13
+ - "lib/**"
14
+ - "sig/**"
15
+ - "core/**"
16
+ - "stdlib/**"
17
+ - "test/**"
18
+ - "Rakefile"
19
+ - "rbs.gemspec"
20
+ # `merge_group` has no `paths` filter, so this runs on every queue entry.
21
+ merge_group: {}
22
+
23
+ permissions:
24
+ contents: read
25
+
26
+ env:
27
+ # Keep in sync with .github/workflows/wasm.yml.
28
+ WASI_SDK_VERSION: "33"
29
+ WASI_SDK_RELEASE: "33.0"
30
+
31
+ jobs:
32
+ test:
33
+ name: jruby
34
+ runs-on: ubuntu-latest
35
+ steps:
36
+ - uses: actions/checkout@v7
37
+ - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
38
+
39
+ # Build the .wasm and fetch the Chicory jars with CRuby + the WASI SDK,
40
+ # then run RBS itself on JRuby against those artifacts.
41
+ - name: Set up Ruby (to assemble the WebAssembly runtime)
42
+ uses: ruby/setup-ruby@v1
43
+ with:
44
+ ruby-version: ruby
45
+ bundler: none
46
+ - name: Update rubygems & bundler
47
+ run: gem update --system
48
+ - name: Install gems
49
+ run: |
50
+ bundle config set --local without libs:profilers
51
+ bundle install --jobs 4 --retry 3
52
+ - name: Install the WASI SDK
53
+ run: |
54
+ url="https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION}/wasi-sdk-${WASI_SDK_RELEASE}-x86_64-linux.tar.gz"
55
+ mkdir -p "$HOME/wasi-sdk"
56
+ curl -sSL "$url" | tar xz --strip-components=1 -C "$HOME/wasi-sdk"
57
+ echo "WASI_SDK_PATH=$HOME/wasi-sdk" >> "$GITHUB_ENV"
58
+ - name: Build rbs_parser.wasm
59
+ run: bundle exec rake wasm:jruby_setup
60
+
61
+ - name: Set up JRuby
62
+ uses: ruby/setup-ruby@v1
63
+ with:
64
+ ruby-version: jruby
65
+ bundler: none
66
+ - name: Install runtime and test gems
67
+ run: gem install prism rake rake-compiler test-unit rdoc rspec minitest json-schema pry --no-document
68
+ # jar-dependencies resolves through the JVM, so download the Chicory/ASM
69
+ # jars into ~/.m2 here on JRuby (jar-dependencies is not available in the
70
+ # CRuby step above).
71
+ - name: Download the Chicory and ASM jars
72
+ run: jruby -S rake wasm:install_jars
73
+ - name: Run the test suite on JRuby
74
+ run: jruby -S rake test
@@ -0,0 +1,235 @@
1
+ name: Release gems
2
+
3
+ # Builds, publishes, and announces a release. Dispatch it with the commit being
4
+ # released and the version that commit declares.
5
+ #
6
+ # Everything is built from `commit`, not from wherever the default branch happens to
7
+ # be when the run starts, so the release describes a state that is already immutable.
8
+ # `version` is the same fact stated a second time -- the run stops before anything is
9
+ # built unless it matches the `RBS::VERSION` of that commit, so dispatching the wrong
10
+ # commit, or the right one under the wrong name, is a failed run rather than a gem
11
+ # that has to be yanked.
12
+ #
13
+ # `dry_run` builds and checks both gems and stops before the tag, which is how the
14
+ # build is exercised without releasing anything.
15
+ #
16
+ # | Gem | Platform | Parser |
17
+ # | -------------------- | ------------- | -------------------------------- |
18
+ # | `rbs-X.Y.Z.gem` | `ruby` (MRI) | C extension, compiled on install |
19
+ # | `rbs-X.Y.Z-java.gem` | `java` (JRuby)| `rbs_parser.wasm`, prebuilt here |
20
+ #
21
+ # See docs/release.md. The `java` gem is built on CRuby: the platform comes from
22
+ # `RBS_PLATFORM`, not from the engine running `gem build`. JRuby is only needed to
23
+ # run the result, which the workflow does before it would publish anything.
24
+ #
25
+ # One job on purpose. Tagging, pushing the gems, and opening the GitHub release
26
+ # all belong to a single release, and keeping them in one place keeps their order
27
+ # readable -- the tag is created once both gems are known to build and run, and
28
+ # before anything is published, so the reversible step comes before the irreversible
29
+ # one.
30
+ #
31
+ # The file name is what the RubyGems trusted publisher for `rbs` is registered
32
+ # against, so it cannot be renamed without registering the new name first.
33
+
34
+ on:
35
+ workflow_dispatch:
36
+ inputs:
37
+ commit:
38
+ description: "Commit to release, as a full 40-character SHA"
39
+ required: true
40
+ version:
41
+ description: "Version to release, without the leading `v` (e.g. `4.1.2`)"
42
+ required: true
43
+ dry_run:
44
+ description: "Build and check the gems without tagging or publishing anything"
45
+ type: boolean
46
+ default: false
47
+
48
+ permissions:
49
+ contents: read
50
+
51
+ env:
52
+ # Keep in sync with .github/workflows/wasm.yml and .github/workflows/jruby.yml.
53
+ WASI_SDK_VERSION: "33"
54
+ WASI_SDK_RELEASE: "33.0"
55
+
56
+ jobs:
57
+ release:
58
+ name: release
59
+ runs-on: ubuntu-latest
60
+ permissions:
61
+ contents: write # push the tag, publish the GitHub release
62
+ id-token: write # trusted publishing to RubyGems
63
+ env:
64
+ # The inputs are read through the environment rather than interpolated into
65
+ # the scripts below.
66
+ COMMIT: ${{ inputs.commit }}
67
+ VERSION: ${{ inputs.version }}
68
+ TAG: v${{ inputs.version }}
69
+ steps:
70
+ # The gemspec takes its file list from `git ls-files`, so both gems are built
71
+ # from the committed state -- of the dispatched commit, since that is what is
72
+ # checked out. The full history is needed to tell which branches contain it.
73
+ - uses: actions/checkout@v7
74
+ with:
75
+ ref: ${{ inputs.commit }}
76
+ fetch-depth: 0
77
+
78
+ # Before anything is installed or built: these are the two things the release
79
+ # is named after and built from, and a mistake in either is cheapest to catch
80
+ # here.
81
+ - name: Check the inputs
82
+ run: |
83
+ if [[ ! "$COMMIT" =~ ^[0-9a-f]{40}$ ]]; then
84
+ echo "::error::\`$COMMIT\` is not a full 40-character SHA. A release names one exact commit."
85
+ exit 1
86
+ fi
87
+ if [[ ! "$VERSION" =~ ^[0-9][0-9a-zA-Z.]*$ ]]; then
88
+ echo "::error::\`$VERSION\` is not a version number. Pass it without the leading \`v\`."
89
+ exit 1
90
+ fi
91
+
92
+ # A release proper is cut from the default branch, while a patch release can
93
+ # be cut from a release branch, so which branch the commit is on is not this
94
+ # workflow's business. That it is on one is: a commit no branch contains is
95
+ # one that nothing in the repository leads to any more.
96
+ git fetch --no-tags origin "+refs/heads/*:refs/remotes/origin/*"
97
+ branches=$(git branch --remotes --contains "$COMMIT" --format "%(refname:lstrip=3)")
98
+ if [ -z "$branches" ]; then
99
+ echo "::error::$COMMIT is not on any branch."
100
+ exit 1
101
+ fi
102
+ echo "Branches containing $COMMIT:"
103
+ printf '%s\n' "$branches"
104
+
105
+ # A tag that already exists is a version that has already been released, and
106
+ # pushing it would fail after the build rather than before it.
107
+ - name: Check that the tag does not exist
108
+ if: ${{ !inputs.dry_run }}
109
+ run: |
110
+ if git ls-remote --exit-code --tags origin "refs/tags/$TAG" > /dev/null; then
111
+ echo "::error::$TAG already exists, so $VERSION has been released."
112
+ exit 1
113
+ fi
114
+
115
+ - name: Set up Ruby
116
+ uses: ruby/setup-ruby@v1
117
+ with:
118
+ ruby-version: ruby
119
+ bundler: none
120
+ - name: Update rubygems & bundler
121
+ run: gem update --system
122
+ - name: Install gems
123
+ run: |
124
+ bundle config set --local without libs:profilers
125
+ bundle install --jobs 4 --retry 3
126
+
127
+ # Fails before a minute is spent on the build, and before anything is pushed:
128
+ # the version has to be the one the released commit declares, and -- unless
129
+ # this is a `.dev.N` release -- the one CHANGELOG.md is written up for.
130
+ - name: Check the version and the changelog
131
+ run: bundle exec rake "gem:check_release[$VERSION]"
132
+
133
+ - name: Build the ruby gem
134
+ run: |
135
+ mkdir -p pkg
136
+ gem build rbs.gemspec -o "pkg/rbs-$VERSION.gem"
137
+
138
+ # `rake wasm:jruby_setup` compiles src/**/*.c to WebAssembly and copies the
139
+ # result to lib/rbs/wasm/, where the gemspec picks it up. clang runs as a
140
+ # subprocess, so this works on CRuby.
141
+ - name: Install the WASI SDK
142
+ run: |
143
+ url="https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION}/wasi-sdk-${WASI_SDK_RELEASE}-x86_64-linux.tar.gz"
144
+ mkdir -p "$HOME/wasi-sdk"
145
+ curl -sSL "$url" | tar xz --strip-components=1 -C "$HOME/wasi-sdk"
146
+ echo "WASI_SDK_PATH=$HOME/wasi-sdk" >> "$GITHUB_ENV"
147
+ - name: Build rbs_parser.wasm
148
+ run: bundle exec rake wasm:jruby_setup
149
+
150
+ - name: Build the java gem
151
+ env:
152
+ RBS_PLATFORM: java
153
+ run: gem build rbs.gemspec -o "pkg/rbs-$VERSION-java.gem"
154
+
155
+ # `git ls-files` vouches for everything else, but rbs_parser.wasm is a build
156
+ # artifact, so the java gem is the one that can come out quietly wrong.
157
+ - name: Check the built gems
158
+ run: |
159
+ ruby -rrubygems/package -e '
160
+ ruby_gem, java_gem = ARGV.map { Gem::Package.new(_1).spec }
161
+
162
+ raise "unexpected platform: #{ruby_gem.platform}" unless ruby_gem.platform.to_s == "ruby"
163
+ raise "the C extension is not declared" if ruby_gem.extensions.empty?
164
+
165
+ raise "unexpected platform: #{java_gem.platform}" unless java_gem.platform.to_s == "java"
166
+ raise "rbs_parser.wasm is missing" unless java_gem.files.include?("lib/rbs/wasm/rbs_parser.wasm")
167
+ raise "the java gem must not declare an extension" unless java_gem.extensions.empty?
168
+
169
+ [ruby_gem, java_gem].each { puts "#{_1.full_name}: #{_1.files.size} files" }
170
+ ' "pkg/rbs-$VERSION.gem" "pkg/rbs-$VERSION-java.gem"
171
+
172
+ # The checks above cannot tell whether rbs_parser.wasm actually runs. Install
173
+ # the gem the way a user would -- jar-dependencies fetches Chicory and ASM
174
+ # from Maven during the install -- and parse something with it, so the
175
+ # WebAssembly runtime is exercised end to end before anything is published.
176
+ - name: Set up JRuby
177
+ uses: ruby/setup-ruby@v1
178
+ with:
179
+ ruby-version: jruby
180
+ bundler: none
181
+ - name: Check the java gem on JRuby
182
+ run: |
183
+ gem install "pkg/rbs-$VERSION-java.gem"
184
+ ruby -e '
185
+ require "rbs"
186
+ _, _, decls = RBS::Parser.parse_signature("class Foo end")
187
+ names = decls.map { _1.name.to_s }
188
+ raise "parsed #{names.inspect}, expected [\"Foo\"]" unless names == ["Foo"]
189
+ puts "#{RUBY_ENGINE} #{RUBY_VERSION}: rbs #{RBS::VERSION} parses through the WebAssembly runtime"
190
+ '
191
+
192
+ - name: Switch back to CRuby
193
+ uses: ruby/setup-ruby@v1
194
+ with:
195
+ ruby-version: ruby
196
+ bundler: none
197
+
198
+ # Uploaded before publishing, so a failed push still leaves the gems behind.
199
+ # This is also where a dry run ends.
200
+ - uses: actions/upload-artifact@v7
201
+ with:
202
+ name: gems
203
+ path: pkg/*.gem
204
+ if-no-files-found: error
205
+
206
+ # Everything below runs only for a real release.
207
+
208
+ # The tag comes after the gems are known to build and run, and before anything
209
+ # is published: a tag can be deleted, while a version pushed to RubyGems can
210
+ # only be yanked. What it names was decided by the checkout rather than by the
211
+ # tagging, so nothing rests on it being created first.
212
+ - name: Tag the release
213
+ if: ${{ !inputs.dry_run }}
214
+ run: |
215
+ git config user.name "github-actions[bot]"
216
+ git config user.email "github-actions[bot]@users.noreply.github.com"
217
+ bundle exec rake gem:tag
218
+
219
+ - name: Configure RubyGems credentials
220
+ if: ${{ !inputs.dry_run }}
221
+ # No floating major tag on this action, so the exact release is pinned.
222
+ uses: rubygems/configure-rubygems-credentials@v2.1.0
223
+
224
+ - name: Push the gems
225
+ if: ${{ !inputs.dry_run }}
226
+ run: |
227
+ gem push "pkg/rbs-$VERSION.gem"
228
+ gem push "pkg/rbs-$VERSION-java.gem"
229
+
230
+ # Last, so that a failed push never announces a release that has no gems.
231
+ - name: Publish the GitHub release
232
+ if: ${{ !inputs.dry_run }}
233
+ env:
234
+ GH_TOKEN: ${{ github.token }}
235
+ run: bundle exec rake gem:gh_release
@@ -7,13 +7,16 @@ on:
7
7
  pull_request: {}
8
8
  merge_group: {}
9
9
 
10
+ permissions:
11
+ contents: read
12
+
10
13
  jobs:
11
14
  test:
12
15
  runs-on: "ubuntu-latest"
13
16
  strategy:
14
17
  fail-fast: false
15
18
  matrix:
16
- ruby: ['3.2', '3.3', '3.4', '4.0', head]
19
+ ruby: ['3.3', '3.4', '4.0', head]
17
20
  rubyopt: [""]
18
21
  job:
19
22
  - test
@@ -37,7 +40,7 @@ jobs:
37
40
  env:
38
41
  RANDOMIZE_STDLIB_TEST_ORDER: "true"
39
42
  steps:
40
- - uses: actions/checkout@v6
43
+ - uses: actions/checkout@v7
41
44
  - uses: ruby/setup-ruby@v1
42
45
  with:
43
46
  ruby-version: ${{ matrix.ruby }}
@@ -87,7 +90,7 @@ jobs:
87
90
  matrix:
88
91
  ruby: ['4.0', head]
89
92
  steps:
90
- - uses: actions/checkout@v6
93
+ - uses: actions/checkout@v7
91
94
  - name: Install dependencies
92
95
  run: |
93
96
  brew install ruby-build
@@ -116,3 +119,40 @@ jobs:
116
119
  run: |
117
120
  bin/setup
118
121
  - run: bundle exec rake clean compile_c99
122
+
123
+ clang_compile:
124
+ runs-on: macos-latest
125
+ strategy:
126
+ fail-fast: false
127
+ matrix:
128
+ ruby: ['4.0', head]
129
+ steps:
130
+ - uses: actions/checkout@v7
131
+ - name: Install dependencies
132
+ run: |
133
+ brew install ruby-build
134
+ - uses: ruby/setup-ruby@v1
135
+ with:
136
+ ruby-version: ${{ matrix.ruby }}
137
+ bundler: none
138
+ - name: Set working directory as safe
139
+ run: git config --global --add safe.directory $(pwd)
140
+ - name: Update rubygems & bundler
141
+ run: |
142
+ ruby -v
143
+ gem update --system
144
+ - name: install erb
145
+ run: gem install erb
146
+ - name: clang version
147
+ run: clang --version
148
+ - name: bundle config set force_ruby_platform true if head
149
+ if: ${{ contains(matrix.ruby, 'head') }}
150
+ run: |
151
+ bundle config set force_ruby_platform true
152
+ - name: Ignore Gemfile.lock's BUNDLED WITH on ruby-head
153
+ if: ${{ contains(matrix.ruby, 'head') }}
154
+ run: bundle config set --local version system
155
+ - name: bin/setup
156
+ run: |
157
+ bin/setup
158
+ - run: bundle exec rake clean compile
@@ -8,12 +8,15 @@ on:
8
8
  paths:
9
9
  - ".github/workflows/rust.yml"
10
10
  - "rust/**"
11
- - "include/**"
12
- - "src/**"
11
+ # `merge_group` has no `paths` filter, so this runs on every queue entry.
12
+ merge_group: {}
13
13
 
14
14
  env:
15
15
  RUSTFLAGS: "-D warnings"
16
16
 
17
+ permissions:
18
+ contents: read
19
+
17
20
  jobs:
18
21
  test:
19
22
  name: cargo:test
@@ -23,7 +26,7 @@ jobs:
23
26
  matrix:
24
27
  os: [ubuntu-latest, macos-latest, windows-latest]
25
28
  steps:
26
- - uses: actions/checkout@v6
29
+ - uses: actions/checkout@v7
27
30
  - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
28
31
  - name: Set up Ruby
29
32
  uses: ruby/setup-ruby@v1
@@ -42,7 +45,7 @@ jobs:
42
45
  run: |
43
46
  rustup update --no-self-update stable
44
47
  rustup default stable
45
- - uses: actions/cache@v5
48
+ - uses: actions/cache@v6
46
49
  with:
47
50
  path: |
48
51
  ~/.cargo/registry
@@ -61,7 +64,7 @@ jobs:
61
64
  runs-on: ubuntu-latest
62
65
  continue-on-error: true
63
66
  steps:
64
- - uses: actions/checkout@v6
67
+ - uses: actions/checkout@v7
65
68
  - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
66
69
  - name: Set up git identity
67
70
  run: |
@@ -84,7 +87,7 @@ jobs:
84
87
  run: |
85
88
  rustup update --no-self-update stable
86
89
  rustup default stable
87
- - uses: actions/cache@v5
90
+ - uses: actions/cache@v6
88
91
  with:
89
92
  path: |
90
93
  ~/.cargo/registry
@@ -103,7 +106,7 @@ jobs:
103
106
  runs-on: ubuntu-latest
104
107
  continue-on-error: true
105
108
  steps:
106
- - uses: actions/checkout@v6
109
+ - uses: actions/checkout@v7
107
110
  - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
108
111
  - name: Set up git identity
109
112
  run: |
@@ -126,7 +129,7 @@ jobs:
126
129
  run: |
127
130
  rustup update --no-self-update stable
128
131
  rustup default stable
129
- - uses: actions/cache@v5
132
+ - uses: actions/cache@v6
130
133
  with:
131
134
  path: |
132
135
  ~/.cargo/registry
@@ -144,7 +147,7 @@ jobs:
144
147
  name: cargo:lint
145
148
  runs-on: ubuntu-latest
146
149
  steps:
147
- - uses: actions/checkout@v6
150
+ - uses: actions/checkout@v7
148
151
  - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
149
152
  - name: Set up Ruby
150
153
  uses: ruby/setup-ruby@v1
@@ -164,7 +167,7 @@ jobs:
164
167
  rustup update --no-self-update stable
165
168
  rustup default stable
166
169
  rustup component add --toolchain stable clippy rustfmt
167
- - uses: actions/cache@v5
170
+ - uses: actions/cache@v6
168
171
  with:
169
172
  path: |
170
173
  ~/.cargo/registry
@@ -0,0 +1,54 @@
1
+ name: TruffleRuby
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request: {}
8
+ merge_group: {}
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ jobs:
14
+ test:
15
+ runs-on: "ubuntu-latest"
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ ruby: ['truffleruby']
20
+ job:
21
+ - test
22
+ env:
23
+ RANDOMIZE_STDLIB_TEST_ORDER: "true"
24
+ # TruffleRuby warns and falls back to US-ASCII unless the locale is UTF-8.
25
+ LANG: "en_US.UTF-8"
26
+ steps:
27
+ - uses: actions/checkout@v7
28
+ - uses: ruby/setup-ruby@v1
29
+ with:
30
+ ruby-version: ${{ matrix.ruby }}
31
+ bundler: none
32
+ - name: Set working directory as safe
33
+ run: git config --global --add safe.directory $(pwd)
34
+ - name: Install dependencies
35
+ run: |
36
+ sudo apt-get update
37
+ sudo apt-get install -y libdb-dev curl autoconf automake m4 libtool python3
38
+ - name: Update rubygems & bundler
39
+ run: |
40
+ ruby -v
41
+ gem update --system
42
+ - name: install erb
43
+ run: gem install erb
44
+ - name: bundle config
45
+ run: |
46
+ # Profilers and the typecheck tooling are not needed for the smoke test,
47
+ # and some of them do not support TruffleRuby.
48
+ bundle config set --local without 'profilers typecheck_test'
49
+ - name: bin/setup
50
+ run: |
51
+ bin/setup
52
+ - name: Run test
53
+ run: |
54
+ bundle exec rake ${{ matrix.job }}