Skip to content

Commit f746310

Browse files
authored
chore: add devcontainer contributor workflow [DX-822] (#274)
* chore: add devcontainer contributor workflow * fix: make Ruby devcontainer Bundler writable * fix: replace deprecated workflow runtimes * docs: clarify devcontainer workflows
1 parent 8a32055 commit f746310

File tree

7 files changed

+108
-57
lines changed

7 files changed

+108
-57
lines changed

.circleci/config.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.devcontainer/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ARG RUBY_VERSION=3.4
2+
FROM mcr.microsoft.com/devcontainers/ruby:1-${RUBY_VERSION}-bookworm
3+
4+
RUN gem install bundler:2.3.26 --no-document

.devcontainer/devcontainer.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "contentful.rb",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"context": "..",
6+
"args": {
7+
"RUBY_VERSION": "${localEnv:RUBY_VERSION:3.4}"
8+
}
9+
},
10+
"containerEnv": {
11+
"BUNDLE_APP_CONFIG": "/home/vscode/.bundle",
12+
"BUNDLE_PATH": "/home/vscode/.bundle/vendor"
13+
},
14+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
15+
"remoteUser": "vscode",
16+
"postCreateCommand": "bundle _2.3.26_ install",
17+
"customizations": {
18+
"vscode": {
19+
"extensions": [
20+
"Shopify.ruby-lsp"
21+
]
22+
}
23+
}
24+
}

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test-and-lint:
14+
name: Test and lint (Ruby ${{ matrix.ruby-version }})
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
ruby-version: ["3.2", "3.3", "3.4"]
20+
steps:
21+
- uses: actions/checkout@v5
22+
23+
- name: Install devcontainer CLI
24+
run: npm install -g @devcontainers/cli@0
25+
26+
- name: Run tests and lint checks in dev container
27+
env:
28+
RUBY_VERSION: ${{ matrix.ruby-version }}
29+
run: |
30+
devcontainer up --workspace-folder .
31+
devcontainer exec --workspace-folder . bash -lc "bundle _2.3.26_ exec rake rspec_rubocop"

.github/workflows/codeql.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Contributing
2+
3+
Thanks for helping improve `contentful.rb`.
4+
5+
## Development with Dev Containers
6+
7+
This repository includes a `.devcontainer` configuration for a reproducible local setup. GitHub Actions uses the same devcontainer configuration for CI.
8+
9+
### Visual Studio Code
10+
11+
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.
12+
13+
### Terminal or other editors
14+
15+
Install Docker and the Dev Container CLI (`npm install -g @devcontainers/cli`). From the repository root, run:
16+
17+
```bash
18+
devcontainer up --workspace-folder .
19+
devcontainer exec --workspace-folder . bash
20+
```
21+
22+
### Verify the environment
23+
24+
```bash
25+
bundle exec rake rspec_rubocop
26+
```
27+
28+
## Other Useful Commands
29+
30+
```bash
31+
bundle exec rake spec
32+
bundle exec rake rubocop
33+
```
34+
35+
## Pull Requests
36+
37+
1. Fork the repository and create a branch for your change.
38+
2. Run the relevant checks from the dev container.
39+
3. Open a pull request with a short summary of the change and any follow-up context.

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
<img src="https://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT License" />
2222
</a>
2323
&nbsp;
24-
<a href="https://app.circleci.com/pipelines/github/contentful/contentful.rb?branch=master">
25-
<img src="https://circleci.com/gh/contentful/contentful.rb/tree/master.svg?style=svg" alt="CircleCI">
24+
<a href="https://github.com/contentful/contentful.rb/actions/workflows/ci.yml">
25+
<img src="https://github.com/contentful/contentful.rb/actions/workflows/ci.yml/badge.svg" alt="CI">
2626
</a>
2727
</p>
2828

@@ -758,6 +758,14 @@ For more information on the internal changes present in the 2.x release, please
758758

759759
We appreciate any help on our repositories. For more details about how to contribute see our [CONTRIBUTING.md](CONTRIBUTING.md) document.
760760

761+
For a reproducible local setup, open this repository in its included dev container. The container installs the project dependencies automatically when it is created.
762+
763+
After the container is ready, run:
764+
765+
```bash
766+
bundle exec rake rspec_rubocop
767+
```
768+
761769
## License
762770

763771
This repository is published under the [MIT](LICENSE.txt) license.

0 commit comments

Comments
 (0)