From 6fd4a4c38cd6379bfdc208e6634ac263a8ba15ba Mon Sep 17 00:00:00 2001 From: Cirdes Henrique Date: Mon, 14 Apr 2025 18:58:29 +0000 Subject: [PATCH 1/4] Use devcontainers for CI workflows This PR updates our GitHub Actions workflows to use devcontainers instead of directly setting up the environment on the runner. This approach: - Ensures CI runs in the same environment as development - Simplifies workflow configuration - Reduces maintenance by centralizing environment setup in the devcontainer - Increases CI timeout to accommodate container build time --- .github/workflows/main.yml | 72 ++++++++++++++------------------------ 1 file changed, 26 insertions(+), 46 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f55b188..65ab7a6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,69 +11,49 @@ on: jobs: scan: - timeout-minutes: 10 + timeout-minutes: 15 runs-on: ubuntu-latest - + steps: - name: Checkout code uses: actions/checkout@v4 - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 + + - name: Build and run dev container task + uses: devcontainers/ci@v0.3 with: - bundler-cache: true + runCmd: | + bundle install + # Add scan commands here lint: - timeout-minutes: 10 + timeout-minutes: 15 runs-on: ubuntu-latest + steps: - name: Checkout code uses: actions/checkout@v4 - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 + + - name: Build and run dev container task + uses: devcontainers/ci@v0.3 with: - bundler-cache: true - - - name: Lint code for consistent style - run: bundle exec standardrb + runCmd: bundle exec standardrb test: - timeout-minutes: 10 + timeout-minutes: 15 runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v4 - - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - run_install: false - - - name: Setup Node - uses: actions/setup-node@v4 + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build and run dev container task + uses: devcontainers/ci@v0.3 with: - node-version-file: ".node-version" - cache: 'pnpm' - - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y -qq libvips - pnpm install - - - name: Run tests - env: - RAILS_ENV: test - # RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} - run: | - bin/rails test:prepare - bin/rails db:test:prepare - bin/rails test + runCmd: | + bin/setup --skip-server + bin/rails test:prepare + bin/rails db:test:prepare + bin/rails test heroku-deploy: if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/PhlexUI-web' }} From f0b9175662349a1156493b4d8449ced5e8644a4a Mon Sep 17 00:00:00 2001 From: Cirdes Henrique Date: Mon, 14 Apr 2025 19:16:42 +0000 Subject: [PATCH 2/4] use devcontainers for CI workflows --- .github/workflows/main.yml | 45 ++++++++------------------------------ 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 65ab7a6..18b88ed 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,42 +2,14 @@ name: CI on: pull_request: - branches: - - "*" + types: + - opened + - reopened + - synchronize + - ready_for_review push: - branches: - - main - - v1 - + branches: "main" jobs: - scan: - timeout-minutes: 15 - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Build and run dev container task - uses: devcontainers/ci@v0.3 - with: - runCmd: | - bundle install - # Add scan commands here - - lint: - timeout-minutes: 15 - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Build and run dev container task - uses: devcontainers/ci@v0.3 - with: - runCmd: bundle exec standardrb - test: timeout-minutes: 15 runs-on: ubuntu-latest @@ -54,10 +26,11 @@ jobs: bin/rails test:prepare bin/rails db:test:prepare bin/rails test + bundle exec standardrb heroku-deploy: if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/PhlexUI-web' }} - needs: [lint, test] + needs: [test] runs-on: ubuntu-latest steps: @@ -72,7 +45,7 @@ jobs: fly-deploy: if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - needs: [lint, test] + needs: [test] name: Deploy app runs-on: ubuntu-latest concurrency: deploy-group From 956320d182936a59f9e3da97b7d319aaba967ec0 Mon Sep 17 00:00:00 2001 From: Cirdes Henrique Date: Mon, 14 Apr 2025 19:34:55 +0000 Subject: [PATCH 3/4] unify ci workflow --- .github/workflows/main.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 18b88ed..32672d6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,16 +17,25 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Build and run dev container task uses: devcontainers/ci@v0.3 with: + imageName: ghcr.io/ruby-ui/web-devcontainer + cacheFrom: ghcr.io/ruby-ui/web-devcontainer + push: always runCmd: | - bin/setup --skip-server + bundle exec standardrb bin/rails test:prepare bin/rails db:test:prepare bin/rails test - bundle exec standardrb heroku-deploy: if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/PhlexUI-web' }} From 4aeb8cbda9484a2e9b691ef9e80c364cd694727e Mon Sep 17 00:00:00 2001 From: Cirdes Henrique Date: Mon, 14 Apr 2025 19:43:47 +0000 Subject: [PATCH 4/4] fix permissions --- .github/workflows/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 32672d6..9aa4683 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,6 +13,9 @@ jobs: test: timeout-minutes: 15 runs-on: ubuntu-latest + permissions: + contents: read + packages: write steps: - name: Checkout code