diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index a4fb992..02c2d7f 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -15,6 +15,10 @@ on: permissions: contents: read +env: + SOLARGRAPH_CACHE: ${{ github.workspace }}/vendor/solargraph/cache + BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle + jobs: test: name: Tests (ruby v${{ matrix.ruby-version }}) @@ -39,16 +43,16 @@ jobs: - name: Cache Ruby gems uses: actions/cache@v3 with: - path: vendor/bundle + path: ${{ env.BUNDLE_PATH }} key: bundle-use-ruby-${{ matrix.os }}-${{ matrix.ruby-version }}-${{ hashFiles('solargraph-rspec.gemspec') }} restore-keys: | bundle-use-ruby-${{ matrix.os }}-${{ matrix.ruby-version }}-${{ hashFiles('solargraph-rspec.gemspec') }} - name: Install dependencies run: | - bundle config path vendor/bundle + bundle config path ${{ env.BUNDLE_PATH }} bundle install --jobs 4 --retry 3 # we need this to install appraisal - bundle exec appraisal bundle config path ../vendor/bundle + bundle exec appraisal bundle config path ${{ env.BUNDLE_PATH }} bundle exec appraisal install --jobs 4 --retry 3 # For some reason on ruby 3.1 it defaults to an old version: 1.3.2 # https://github.com/lekemula/solargraph-rspec/actions/runs/17814581205/job/50645370316?pr=22 @@ -59,13 +63,19 @@ jobs: # https://github.com/rubocop/rubocop/issues/10893#issuecomment-1952517060 run: bundle exec rubocop --restart-server + - name: Cache Solargraph YARD and RBS pins for gems + uses: actions/cache@v4 + with: + path: ${{ env.SOLARGRAPH_CACHE }} + key: os-${{ runner.os }}-ruby-${{ matrix.ruby-version }}-solargraph-${{ hashFiles('**/Gemfile.lock') }} + - name: Configure .solargraph.yml run: cp .solargraph.yml.example .solargraph.yml - - name: Solargraph cache RSpec plugins YARD and RBS + - name: Solargraph generate RSpec plugins YARD and RBS pins run: | rspec_plugins=$(bundle exec appraisal bundle exec ruby -r './lib/solargraph-rspec' -e 'puts Solargraph::Rspec::TestHelpers.gem_names.join(" ")' 2>/dev/null | tail -n1) - bundle exec appraisal bundle exec solargraph gems --rebuild $rspec_plugins + bundle exec appraisal bundle exec solargraph gems $rspec_plugins - name: Run tests run: bundle exec appraisal rspec --format progress diff --git a/.github/workflows/typecheck.yml b/.github/workflows/typecheck.yml index 3bb39fc..777c94b 100644 --- a/.github/workflows/typecheck.yml +++ b/.github/workflows/typecheck.yml @@ -16,6 +16,10 @@ on: permissions: contents: read +env: + SOLARGRAPH_CACHE: ${{ github.workspace }}/vendor/solargraph/cache + RUBY_VERSION: 3.4 + jobs: solargraph_typed: name: Solargraph / typed @@ -27,11 +31,15 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.4 - bundler-cache: false + ruby-version: ${{ env.RUBY_VERSION }} + bundler-cache: true # runs bundle install and caches the gems + - name: Cache Solargraph YARD and RBS pins for gems + uses: actions/cache@v4 + with: + path: ${{ env.SOLARGRAPH_CACHE }} + key: os-${{ runner.os }}-ruby-${{ env.RUBY_VERSION }}-solargraph-${{ hashFiles('**/Gemfile.lock') }} - name: Install gems run: | - bundle install bundle update rbs # use latest available for this Ruby version - name: Install gem types run: bundle exec rbs collection install