From 6fb1772fe25eac9c964a8e712d2db4f767965163 Mon Sep 17 00:00:00 2001 From: Andrew Novoselac Date: Fri, 12 Apr 2024 10:28:51 -0400 Subject: [PATCH] Create a workflow for testing generated devcontainer setup This workflow tests the generated devcontainer for new rails apps by: - Generating a new app with the --dev flag - Initializing the dev container that is generated - Generating a model scaffold and running the migrations - Running the tests It tests each of the four supported database configurations. --- .github/workflows/devcontainer-smoke-test.yml | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/devcontainer-smoke-test.yml diff --git a/.github/workflows/devcontainer-smoke-test.yml b/.github/workflows/devcontainer-smoke-test.yml new file mode 100644 index 0000000000000..cf28f6660ac8a --- /dev/null +++ b/.github/workflows/devcontainer-smoke-test.yml @@ -0,0 +1,50 @@ +name: Devcontainer smoke test + +on: [push, pull_request] + +jobs: + build: + name: Devcontainer smoke test + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + strategy: + fail-fast: false + matrix: + DATABASE: + - sqlite3 + - postgresql + - mysql + - trilogy + + steps: + - name: Checkout (GitHub) + uses: actions/checkout@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Ruby 3.3 + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.3 + bundler-cache: true + + - name: Generate rails app + run: bundle exec railties/exe/rails new myapp --database="${{ matrix.DATABASE }}" --dev + + - name: Test devcontainer + uses: devcontainers/ci@v0.3 + with: + subFolder: myapp + imageName: ghcr.io/rails/smoke-test-devcontainer + cacheFrom: ghcr.io/rails/smoke-test-devcontainer + imageTag: ${{ matrix.DATABASE }} + refFilterForPush: refs/heads/main + runCmd: bin/rails g scaffold Post && bin/rails db:migrate && bin/rails test \ No newline at end of file