diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..03b4e9fa --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,44 @@ +name: Tests +on: [push, pull_request] + +env: + RAILS_ENV: test + +jobs: + test: + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:14 + env: + POSTGRES_PASSWORD: postgres + ports: ['5432:5432'] + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + memcached: + image: memcached:alpine + ports: ['11211:11211'] + + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v1 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7 + bundler-cache: true + + - name: Setup environment + run: ./script/gh-action-prepare + + - name: Build assets + run: bundle exec rails assets:precompile + + - name: Run test + run: bundle exec rails test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 331df810..00000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -dist: focal - -cache: - bundler: true - yarn: true - -language: ruby - -rvm: -- 2.7.1 - -services: -- memcached -- postgresql - -addons: - postgresql: 13 - -before_script: -- nvm use 12 -- yarn install -- script/travis_prepare diff --git a/script/travis_prepare b/script/gh-action-prepare similarity index 90% rename from script/travis_prepare rename to script/gh-action-prepare index 7377464a..e3bc80b3 100755 --- a/script/travis_prepare +++ b/script/gh-action-prepare @@ -5,8 +5,10 @@ mkdir -p public/data cat < config/database.yml test: adapter: postgresql + host: '127.0.0.1' port: 5432 username: postgres + password: postgres database: moebooru_test EOF