From cdf5dab858dedf270b6b37894dee8070dcda68e8 Mon Sep 17 00:00:00 2001 From: JasterV <49537445+JasterV@users.noreply.github.com> Date: Sun, 8 Mar 2026 18:13:43 +0100 Subject: [PATCH] feat: migrate to codeberg --- .github/workflows/ci.yml | 93 ---------------------------- .github/workflows/production.yml | 64 ------------------- .github/workflows/review-cleanup.yml | 25 -------- .github/workflows/review.yml | 72 --------------------- .woodpecker/ci.yml | 21 +++++++ .woodpecker/production.yml | 45 ++++++++++++++ config/ci.exs | 52 ++++++++++++++++ 7 files changed, 118 insertions(+), 254 deletions(-) delete mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/production.yml delete mode 100644 .github/workflows/review-cleanup.yml delete mode 100644 .github/workflows/review.yml create mode 100644 .woodpecker/ci.yml create mode 100644 .woodpecker/production.yml create mode 100644 config/ci.exs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index efd6f28..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,93 +0,0 @@ -name: CI - -on: - workflow_dispatch: {} - workflow_call: - -permissions: - contents: read - -env: - MIX_ENV: test - -jobs: - ci: - # Service containers to run with `container-job` - services: - # Label used to access the service container - postgres: - # Docker Hub image - image: postgres - # Provide the password for postgres - env: - POSTGRES_PASSWORD: postgres - # Set health checks to wait until postgres has started - options: >- - --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 - ports: - - 5432:5432 - - name: Run CI on OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}} - runs-on: ubuntu-latest - - strategy: - matrix: - otp: ["27.3"] - elixir: ["1.18.3"] - - steps: - - name: Set up Elixir - uses: erlef/setup-beam@v1 - with: - elixir-version: ${{matrix.elixir}} - otp-version: ${{matrix.otp}} - - - name: Checkout code - uses: actions/checkout@v5 - - # Step: Define how to cache deps. Restores existing cache if present. - - name: Cache deps - id: cache-deps - uses: actions/cache@v4 - env: - cache-name: cache-spazio-solazzo-deps - with: - path: spazio-solazzo/deps - key: ${{ runner.os }}-${{matrix.otp}}-${{matrix.elixir}}-${{ env.cache-name }}-${{ hashFiles('spazio-solazzo/**/mix.lock') }} - restore-keys: | - ${{ runner.os }}-${{matrix.otp}}-${{matrix.elixir}}-${{ env.cache-name }}- - - # Step: Define how to cache the `_build` directory. After the first run, - # this speeds up tests runs a lot. This includes not re-compiling our - # project's downloaded deps every run. - - name: Cache compiled build - id: cache-build - uses: actions/cache@v4 - env: - cache-name: cache-spazio-solazzo-compiled-build - with: - path: spazio-solazzo/_build - key: ${{ runner.os }}-${{matrix.otp}}-${{matrix.elixir}}-${{ env.cache-name }}-${{ hashFiles('spazio-solazzo/**/mix.lock') }} - restore-keys: | - ${{ runner.os }}-${{matrix.otp}}-${{matrix.elixir}}-${{ env.cache-name }} - ${{ runner.os }}-${{matrix.otp}}-${{matrix.elixir}}- - - - name: Install dependencies - run: mix deps.get - - # Step: Compile the project treating any warnings as errors. - - name: Compiles without warnings - run: mix compile --warnings-as-errors - - # Step: Check that the checked in code has already been formatted. - # This step fails if something was found unformatted. - - name: Check Formatting - run: mix format --check-formatted - - # Step: Execute Credo - - name: Run Credo - run: mix credo - - # Step: Execute the tests. - - name: Run tests - run: mix test diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml deleted file mode 100644 index 4afb77f..0000000 --- a/.github/workflows/production.yml +++ /dev/null @@ -1,64 +0,0 @@ -# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/ - -name: Production CI -on: - push: - branches: - - main - -env: - FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} - IMAGE_TAG: registry.fly.io/spazio-solazzo:sha-${{ github.sha }} - -jobs: - ci: - uses: ./.github/workflows/ci.yml - secrets: inherit - - deploy: - name: Deploy app - needs: ci - runs-on: ubuntu-latest - concurrency: deploy-group - - environment: - name: production - - steps: - - uses: actions/checkout@v5 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - uses: superfly/flyctl-actions/setup-flyctl@master - - - name: Authenticate with Fly registry - run: flyctl auth docker - - - name: Build and push Docker image (GHA cache) - uses: docker/build-push-action@v6 - with: - push: true - context: . - tags: ${{ env.IMAGE_TAG }} - cache-from: type=gha - cache-to: type=gha,mode=max - - - name: Set Fly secrets - run: | - flyctl secrets --access-token "$FLY_API_TOKEN" set \ - TOKEN_SIGNING_SECRET="$TOKEN_SIGNING_SECRET" \ - ADMIN_EMAIL="$ADMIN_EMAIL" \ - SPAZIO_SOLAZZO_EMAIL="$SPAZIO_SOLAZZO_EMAIL" \ - FRONT_OFFICE_PHONE_NUMBER="$FRONT_OFFICE_PHONE_NUMBER" \ - RESEND_API_KEY="$RESEND_API_KEY" \ - DATABASE_URL="$DATABASE_URL" - env: - TOKEN_SIGNING_SECRET: ${{ secrets.TOKEN_SIGNING_SECRET }} - ADMIN_EMAIL: ${{ secrets.ADMIN_EMAIL }} - SPAZIO_SOLAZZO_EMAIL: ${{ secrets.SPAZIO_SOLAZZO_EMAIL }} - FRONT_OFFICE_PHONE_NUMBER: ${{ secrets.FRONT_OFFICE_PHONE_NUMBER }} - RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }} - DATABASE_URL: ${{ secrets.DATABASE_URL }} - - - run: flyctl deploy --image ${{ env.IMAGE_TAG }} diff --git a/.github/workflows/review-cleanup.yml b/.github/workflows/review-cleanup.yml deleted file mode 100644 index 5eb3d24..0000000 --- a/.github/workflows/review-cleanup.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Cleanup Review App -on: - pull_request: - types: [closed] - -env: - FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} - APP_NAME: pr-${{ github.event.pull_request.number }}-jasterv-spazio-solazzo - -jobs: - review_app_cleanup: - runs-on: ubuntu-latest - - concurrency: - group: pr-${{ github.event.number }} - - environment: - name: review - - steps: - - name: Destroy PR app - uses: superfly/fly-pr-review-apps@1.5.0 - with: - name: ${{ env.APP_NAME }} - config: fly.review.toml diff --git a/.github/workflows/review.yml b/.github/workflows/review.yml deleted file mode 100644 index ad7b1c2..0000000 --- a/.github/workflows/review.yml +++ /dev/null @@ -1,72 +0,0 @@ -name: Deploy Review App -on: - # Run this workflow on every PR event. Existing review apps will be updated when the PR is updated. - pull_request: - types: [opened, reopened, synchronize] - -env: - FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} - FLY_REGION: ams - FLY_ORG: personal - APP_NAME: pr-${{ github.event.pull_request.number }}-jasterv-spazio-solazzo - -jobs: - ci: - uses: ./.github/workflows/ci.yml - secrets: inherit - - build_and_deploy: - runs-on: ubuntu-latest - needs: ci - - outputs: - url: ${{ steps.deploy.outputs.url }} - # Only run one deployment at a time per PR. - concurrency: - group: pr-${{ github.event.number }} - - environment: - name: review - url: ${{ steps.deploy.outputs.url }} - - steps: - - name: Get code - uses: actions/checkout@v5 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Install flyctl CLI - uses: superfly/flyctl-actions/setup-flyctl@master - - - name: Authenticate with Fly.io registry - run: flyctl auth docker - - - name: Create Fly App before pushing docker image to registry - run: | - flyctl apps create ${{ env.APP_NAME }} --org ${{ env.FLY_ORG }} || true - - - name: Build and push Docker image - uses: docker/build-push-action@v6 - with: - push: true - tags: registry.fly.io/${{ env.APP_NAME }}:sha-${{ github.sha }} - context: . - cache-from: type=gha - cache-to: type=gha,mode=max - - - name: Deploy PR app to Fly.io - id: deploy - uses: superfly/fly-pr-review-apps@1.5.0 - with: - name: ${{ env.APP_NAME }} - config: fly.review.toml - secrets: | - TOKEN_SIGNING_SECRET=${{ secrets.TOKEN_SIGNING_SECRET }} - ADMIN_EMAIL=${{ secrets.ADMIN_EMAIL }} - SPAZIO_SOLAZZO_EMAIL=${{ secrets.SPAZIO_SOLAZZO_EMAIL }} - FRONT_OFFICE_PHONE_NUMBER=${{ secrets.FRONT_OFFICE_PHONE_NUMBER }} - RESEND_API_KEY=${{ secrets.RESEND_API_KEY }} - DATABASE_URL=${{ secrets.DATABASE_URL }} - SECRET_KEY_BASE=${{ secrets.SECRET_KEY_BASE }} - PHX_HOST=${{ env.APP_NAME }}.fly.dev diff --git a/.woodpecker/ci.yml b/.woodpecker/ci.yml new file mode 100644 index 0000000..7f49537 --- /dev/null +++ b/.woodpecker/ci.yml @@ -0,0 +1,21 @@ +when: + event: [push, pull_request] + branch: main + +steps: + ci: + image: elixir:1.18.3-otp-27 + commands: + - mix deps.get + - mix compile --warnings-as-errors + - mix format --check-formatted + - mix credo + - mix test + environment: + MIX_ENV: ci + +services: + postgres: + image: postgres:15-alpine + environment: + POSTGRES_PASSWORD: postgres diff --git a/.woodpecker/production.yml b/.woodpecker/production.yml new file mode 100644 index 0000000..6c213b9 --- /dev/null +++ b/.woodpecker/production.yml @@ -0,0 +1,45 @@ +# This ensures the pipeline only runs on the main branch +when: + event: push + branch: main + +depends_on: + - ci + +steps: + # Build and Push Docker Image + # We use the 'kaniko' plugin to build images without needing a Docker daemon (safer/simpler) + build: + image: plugins/kaniko + settings: + registry: registry.fly.io + repo: registry.fly.io/spazio-solazzo + tags: sha-${CI_COMMIT_SHA} + # You'll need to provide Fly credentials to Kaniko + username: x + password: + from_secret: FLY_API_TOKEN + + # 3. Set Secrets and Deploy + deploy: + image: superfly/flyctl:latest + environment: + FLY_API_TOKEN: + from_secret: FLY_API_TOKEN + # Passing the other app secrets + TOKEN_SIGNING_SECRET: { from_secret: TOKEN_SIGNING_SECRET } + ADMIN_EMAIL: { from_secret: ADMIN_EMAIL } + SPAZIO_SOLAZZO_EMAIL: { from_secret: SPAZIO_SOLAZZO_EMAIL } + FRONT_OFFICE_PHONE_NUMBER: { from_secret: FRONT_OFFICE_PHONE_NUMBER } + RESEND_API_KEY: { from_secret: RESEND_API_KEY } + DATABASE_URL: { from_secret: DATABASE_URL } + commands: + - | + flyctl secrets set \ + TOKEN_SIGNING_SECRET="$TOKEN_SIGNING_SECRET" \ + ADMIN_EMAIL="$ADMIN_EMAIL" \ + SPAZIO_SOLAZZO_EMAIL="$SPAZIO_SOLAZZO_EMAIL" \ + FRONT_OFFICE_PHONE_NUMBER="$FRONT_OFFICE_PHONE_NUMBER" \ + RESEND_API_KEY="$RESEND_API_KEY" \ + DATABASE_URL="$DATABASE_URL" + - flyctl deploy --image registry.fly.io/spazio-solazzo:sha-${CI_COMMIT_SHA} diff --git a/config/ci.exs b/config/ci.exs new file mode 100644 index 0000000..4577599 --- /dev/null +++ b/config/ci.exs @@ -0,0 +1,52 @@ +import Config +config :spazio_solazzo, Oban, testing: :manual +config :bcrypt_elixir, log_rounds: 1 +config :ash, policies: [show_policy_breakdowns?: true], disable_async?: true + +config :spazio_solazzo, + token_signing_secret: "RfyHb7pU2R0WQY7TqdzLabS9LPPQosSq", + admin_email: "admin@myapp.com", + spazio_solazzo_email: "noreply@spaziosolazzo.com", + booking_token_signing_secret: + "43vbAIUx9+XswjhBrQ3uk2bapAYmu1WRR/h/zlFDxNd/CAfBypQXcvLv2bbR7TSf", + front_office_phone_number: "+39 36485928" + +# Configure your database +# +# The MIX_TEST_PARTITION environment variable can be used +# to provide built-in test partitioning in CI environment. +# Run `mix help test` for more information. +config :spazio_solazzo, SpazioSolazzo.Repo, + username: "postgres", + password: "postgres", + hostname: "postgres", + database: "spazio_solazzo_test#{System.get_env("MIX_TEST_PARTITION")}", + pool: Ecto.Adapters.SQL.Sandbox, + pool_size: System.schedulers_online() * 2 + +# We don't run a server during test. If one is required, +# you can enable the server option below. +config :spazio_solazzo, SpazioSolazzoWeb.Endpoint, + http: [ip: {127, 0, 0, 1}, port: 4002], + secret_key_base: "qQdHaG3c/trjbfcoDF57u1wf+1pGzb82rxEhqKAzvHyaB4Z2U19MJivy7+wL756P", + server: false + +# In test we don't send emails +config :spazio_solazzo, SpazioSolazzo.Mailer, adapter: Swoosh.Adapters.Local + +# Disable swoosh api client as it is only required for production adapters +config :swoosh, :api_client, false + +# Print only warnings and errors during test +config :logger, level: :warning + +# Initialize plugs at runtime for faster test compilation +config :phoenix, :plug_init_mode, :runtime + +# Enable helpful, but potentially expensive runtime checks +config :phoenix_live_view, + enable_expensive_runtime_checks: true + +# Sort query params output of verified routes for robust url comparisons +config :phoenix, + sort_verified_routes_query_params: true