DEV: Use syntax_tree for formatting #584
Workflow file for this run
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: | |
schedule: | |
- cron: "0 0 * * 0" # weekly | |
permissions: | |
contents: write | |
packages: write | |
env: | |
DOCKER_REPO: ghcr.io/discourse/prometheus_exporter | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
name: Ruby ${{ matrix.ruby }} AR ${{ matrix.activerecord }} | |
timeout-minutes: 10 | |
env: | |
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/ar_${{ matrix.activerecord }}.gemfile | |
strategy: | |
fail-fast: false | |
matrix: | |
ruby: ["3.1", "3.2", "3.3"] | |
activerecord: [61, 70, 71] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: ${{ matrix.ruby }} | |
bundler: latest | |
bundler-cache: true | |
- name: Rubocop | |
run: bundle exec rubocop | |
- name: Syntax tree | |
run: bundle exec stree check Gemfile $(git ls-files '*.rb') $(git ls-files '*.rake') $(git ls-files '*.thor') | |
- name: Run tests | |
run: bundle exec rake | |
publish: | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
needs: build | |
runs-on: ubuntu-latest | |
outputs: | |
new_version_published: ${{ steps.release.outputs.new_version }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Release gem | |
id: release | |
uses: discourse/publish-rubygems-action@v2 | |
env: | |
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} | |
GIT_EMAIL: [email protected] | |
GIT_NAME: discoursebot | |
publish_docker: | |
needs: publish | |
if: needs.publish.outputs.new_version_published == 'true' | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: docker/setup-qemu-action@v2 | |
- uses: docker/setup-buildx-action@v2 | |
- name: Set vars | |
id: vars | |
run: | | |
ruby -r ./lib/prometheus_exporter/version.rb -e 'print "version=#{PrometheusExporter::VERSION}"' >> $GITHUB_OUTPUT | |
- name: Login to Github Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push images | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
push: true | |
platforms: linux/amd64,linux/arm64 | |
build-args: | | |
GEM_VERSION=${{ steps.vars.outputs.version }} | |
tags: | | |
${{ env.DOCKER_REPO }}:${{ steps.vars.outputs.version }} | |
${{ env.DOCKER_REPO }}:latest |