From 2df875397b8f46d88b38f97c48b6556c919d39de Mon Sep 17 00:00:00 2001 From: Toon Willems Date: Thu, 5 Sep 2024 11:38:20 +0200 Subject: [PATCH] add annotate --frozen to the GH workflow --- .github/workflows/annotate.yml | 56 +++++++++++++++++++++++++++++ lib/tasks/auto_annotate_models.rake | 2 +- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/annotate.yml diff --git a/.github/workflows/annotate.yml b/.github/workflows/annotate.yml new file mode 100644 index 000000000000..94db461ace71 --- /dev/null +++ b/.github/workflows/annotate.yml @@ -0,0 +1,56 @@ +name: Make sure annotate is up to date +on: + push: + branches: + - 'main' + pull_request: + types: [opened, synchronize, reopened] +jobs: + test-annotations: + name: test annotations + runs-on: ubuntu-latest + services: + db: + image: postgres:14-alpine + ports: + - '5432:5432' + env: + POSTGRES_DB: lago + POSTGRES_USER: lago + POSTGRES_PASSWORD: lago + env: + RAILS_ENV: test + DATABASE_URL: 'postgres://lago:lago@localhost:5432/lago' + LAGO_REDIS_CACHE_URL: 'redis://localhost:6379' + RAILS_MASTER_KEY: ${{ secrets.RAILS_TEST_KEY }} + SECRET_KEY_BASE: ${{ secrets.SECRET_KEY_BASE }} + LAGO_API_URL: https://api.lago.dev + LAGO_PDF_URL: https://pdf.lago.dev + SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY }} + LAGO_FROM_EMAIL: noreply@getlago.com + LAGO_CLICKHOUSE_ENABLED: true + LAGO_CLICKHOUSE_MIGRATIONS_ENABLED: true + LAGO_CLICKHOUSE_HOST: localhost + LAGO_CLICKHOUSE_DATABASE: default + LAGO_CLICKHOUSE_USERNAME: '' + LAGO_CLICKHOUSE_PASSWORD: '' + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Install Ruby and gems + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.3.4' + bundler-cache: true + - name: Start Clickhouse database + run: | + docker run -d --rm -p 8123:8123 -p 9000:9000 --ulimit nofile=262144:262144 -v ./clickhouse-s3:/var/lib/clickhouse-s3 -v ./ci/clickhouse/config.xml:/etc/clickhouse-server/config.d/config.xml clickhouse/clickhouse-server + shell: bash + - name: Generate RSA keys + run: ./scripts/generate.rsa.sh + - name: Set up Postgres database schema + run: bin/rails db:schema:load:primary + - name: Set up Clickhouse database schema + run: bin/rails db:migrate:clickhouse + - name: run annotate --frozen + run: bundle exec annotate --frozen diff --git a/lib/tasks/auto_annotate_models.rake b/lib/tasks/auto_annotate_models.rake index 650b6663e027..66e89ac81ce4 100644 --- a/lib/tasks/auto_annotate_models.rake +++ b/lib/tasks/auto_annotate_models.rake @@ -3,7 +3,7 @@ # NOTE: only doing this in development as some production environments (Heroku) # NOTE: are sensitive to local FS writes, and besides -- it's just not proper # NOTE: to have a dev-mode tool do its thing in production. -if Rails.env.development? +if Rails.env.development? || Rails.env.test? require 'annotate' task set_annotation_options: :environment do # You can override any of these by setting an environment variable of the