diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index bc937bb..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,23 +0,0 @@ -version: 2.1 - -jobs: - test_and_lint: - parameters: - ruby-version: - type: string - docker: - - image: cimg/ruby:<< parameters.ruby-version >> - steps: - - checkout - - run: gem install bundler:2.3.26 - - run: bundle install - - run: bundle exec rake rspec_rubocop - -workflows: - version: 2 - workflow: - jobs: - - test_and_lint: - matrix: - parameters: - ruby-version: ["3.2", "3.3", "3.4"] \ No newline at end of file diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..38342f9 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,4 @@ +ARG RUBY_VERSION=3.4 +FROM mcr.microsoft.com/devcontainers/ruby:1-${RUBY_VERSION}-bookworm + +RUN gem install bundler:2.3.26 --no-document diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..2a7c32f --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,24 @@ +{ + "name": "contentful.rb", + "build": { + "dockerfile": "Dockerfile", + "context": "..", + "args": { + "RUBY_VERSION": "${localEnv:RUBY_VERSION:3.4}" + } + }, + "containerEnv": { + "BUNDLE_APP_CONFIG": "/home/vscode/.bundle", + "BUNDLE_PATH": "/home/vscode/.bundle/vendor" + }, + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + "remoteUser": "vscode", + "postCreateCommand": "bundle _2.3.26_ install", + "customizations": { + "vscode": { + "extensions": [ + "Shopify.ruby-lsp" + ] + } + } +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7b683a5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: CI + +on: + push: + branches: [master] + pull_request: + branches: [master] + +permissions: + contents: read + +jobs: + test-and-lint: + name: Test and lint (Ruby ${{ matrix.ruby-version }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ruby-version: ["3.2", "3.3", "3.4"] + steps: + - uses: actions/checkout@v5 + + - name: Install devcontainer CLI + run: npm install -g @devcontainers/cli@0 + + - name: Run tests and lint checks in dev container + env: + RUBY_VERSION: ${{ matrix.ruby-version }} + run: | + devcontainer up --workspace-folder . + devcontainer exec --workspace-folder . bash -lc "bundle _2.3.26_ exec rake rspec_rubocop" diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index de95c07..0000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -name: "CodeQL Scan for GitHub Actions Workflows" - -on: - push: - branches: [master] - paths: [".github/workflows/**"] - pull_request: - branches: [master] - paths: [".github/workflows/**"] - -jobs: - analyze: - name: Analyze GitHub Actions workflows - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - steps: - - uses: actions/checkout@v4 - - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: actions - - - name: Run CodeQL Analysis - uses: github/codeql-action/analyze@v3 - with: - category: actions diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..0c49ef3 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,39 @@ +# Contributing + +Thanks for helping improve `contentful.rb`. + +## Development with Dev Containers + +This repository includes a `.devcontainer` configuration for a reproducible local setup. GitHub Actions uses the same devcontainer configuration for CI. + +### Visual Studio Code + +Open the repository in Visual Studio Code, install the Dev Containers extension if needed, then run `Dev Containers: Reopen in Container`. Wait for the container build and post-create setup to finish. + +### Terminal or other editors + +Install Docker and the Dev Container CLI (`npm install -g @devcontainers/cli`). From the repository root, run: + +```bash +devcontainer up --workspace-folder . +devcontainer exec --workspace-folder . bash +``` + +### Verify the environment + +```bash +bundle exec rake rspec_rubocop +``` + +## Other Useful Commands + +```bash +bundle exec rake spec +bundle exec rake rubocop +``` + +## Pull Requests + +1. Fork the repository and create a branch for your change. +2. Run the relevant checks from the dev container. +3. Open a pull request with a short summary of the change and any follow-up context. diff --git a/README.md b/README.md index 8df6f3d..c7026b4 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,8 @@ MIT License   - - CircleCI + + CI

@@ -758,6 +758,14 @@ For more information on the internal changes present in the 2.x release, please We appreciate any help on our repositories. For more details about how to contribute see our [CONTRIBUTING.md](CONTRIBUTING.md) document. +For a reproducible local setup, open this repository in its included dev container. The container installs the project dependencies automatically when it is created. + +After the container is ready, run: + +```bash +bundle exec rake rspec_rubocop +``` + ## License This repository is published under the [MIT](LICENSE.txt) license.