実現したいこと
Github Actions初めてになります。
Github Actionsが用意したデフォルトのymlでまずはRuby on Rails CIを動かそうとしたところエラーになりtest実行できずにいます。
※lintはいったん消しました。
発生している問題・分からないこと
以下の行でエラーになりCIが進まない
yaml
1uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
エラーメッセージ
error
1Run ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf 2Error: Error: input ruby-version needs to be specified if no .ruby-version or .tool-versions file exists 3 at parseRubyEngineAndVersion (/home/runner/work/_actions/ruby/setup-ruby/55283cc23133118229fd3f97f9336ee23a179fcf/dist/index.js:65032:13)
該当のソースコード
yaml
1name: "Ruby on Rails CI" 2on: 3 push: 4 branches: [ "main" ] 5 pull_request: 6 branches: [ "main" ] 7jobs: 8 test: 9 runs-on: ubuntu-latest 10 services: 11 postgres: 12 image: postgres:11-alpine 13 ports: 14 - "5432:5432" 15 env: 16 POSTGRES_DB: rails_test 17 POSTGRES_USER: rails 18 POSTGRES_PASSWORD: password 19 env: 20 RAILS_ENV: test 21 DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test" 22 steps: 23 - name: Checkout code 24 uses: actions/checkout@v3 25 # Add or replace dependency steps here 26 - name: Install Ruby and gems 27 uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0 28 with: 29 ruby-version: .ruby-version 30 bundler-cache: true 31 # Add or replace database setup steps here 32 - name: Set up database schema 33 run: bin/rails db:schema:load 34 # Add or replace test runners here 35 - name: Run tests 36 run: bin/rake 37
試したこと・調べたこと
- teratailやGoogle等で検索した
- ソースコードを自分なりに変更した
- 知人に聞いた
- その他
上記の詳細・結果
エラーメッセージでググって以下のように色々と修正してみました。
yaml
1 2uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0 3 with: 4 ruby-version: default #これを追加 5 bundler-cache: true 6
これはエラーメッセージ変わらず。
次に以下のように修正してみました。
yaml
1 name: Install Ruby and gems 2 uses: ruby/setup-ruby@v1 #バージョンを変更 3 with: 4 ruby-version: default 5 bundler-cache: true
これもエラーメッセージ変わらず。
こちらを参考に
ruby-version:の箇所を変更修正してみました。
yaml
1 - name: Install Ruby and gems 2 uses: ruby/setup-ruby@v1 3 with: 4 ruby-version: .ruby-version #このように変更 5 bundler-cache: true
エラーメッセージは変わりました。
Error: Error: ENOENT: no such file or directory, open '.ruby-version'
at Object.readFileUtf8 (node:internal/fs/sync:25:18)
CIやActionsが初めてで検討違いしていたらすみません。
分かる方教えて下さい。
宜しくお願い致します。
補足
railsアプリは、最新の
ruby 3.3.0
Rails 7.1.3
です。
あなたの回答
tips
プレビュー