DEV: Update CI dependencies (#354) #322
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: "3.3" | |
bundler-cache: true | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: npm | |
- name: Setup npm | |
run: npm install | |
- name: Rubocop | |
run: bundle exec rubocop | |
- name: ESLint | |
run: npx eslint . | |
test: | |
runs-on: ubuntu-latest | |
name: Ruby ${{ matrix.ruby }} (redis ${{ matrix.redis }}) | |
timeout-minutes: 10 | |
env: | |
PGHOST: localhost | |
PGPASSWORD: postgres | |
PGUSER: postgres | |
strategy: | |
fail-fast: false | |
matrix: | |
ruby: ["2.6", "2.7", "3.0", "3.1"] | |
redis: [5, 6] | |
services: | |
postgres: | |
image: postgres:16 | |
env: | |
POSTGRES_DB: message_bus_test | |
POSTGRES_PASSWORD: postgres | |
ports: | |
- 5432:5432 | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
redis: | |
image: ${{ format('redis:{0}', matrix.redis) }} | |
ports: | |
- 6379:6379 | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: ${{ matrix.ruby }} | |
bundler-cache: true | |
- name: Tests | |
env: | |
TESTOPTS: --verbose | |
run: bundle exec rake | |
publish: | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
needs: [lint, test] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Release gem | |
uses: discourse/publish-rubygems-action@v3 | |
id: publish-gem | |
env: | |
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} | |
GIT_EMAIL: [email protected] | |
GIT_NAME: discoursebot | |
- name: Update package version | |
if: steps.publish-gem.outputs.new_version == 'true' | |
run: | | |
VERSION=$(ruby -r './lib/message_bus/version' -e 'puts MessageBus::VERSION') | |
sed -i "s/0.0.0-version-placeholder/$VERSION/" package.json | |
git config --global user.email "[email protected]" | |
git config --global user.name "Discourse CI" | |
git add package.json | |
git commit -m 'bump' | |
- name: Publish package | |
uses: JS-DevTools/npm-publish@v3 | |
if: steps.publish-gem.outputs.new_version == 'true' | |
with: | |
token: ${{ secrets.NPM_TOKEN }} |