Skip to content

Commit 7ae7790

Browse files
authored
Initial structure and CI/CD. (#2)
* feat: Basic workflows for the gem * feat: Initial structure, working (empty) default rake task
1 parent 972dc72 commit 7ae7790

19 files changed

+837
-1
lines changed

.github/workflows/container.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
name: Publish OCI Container
3+
on: # yamllint disable-line rule:truthy
4+
workflow_call:
5+
inputs:
6+
tag:
7+
description: 'The tag to use for the container image'
8+
required: false
9+
type: string
10+
workflow_dispatch:
11+
inputs:
12+
tag:
13+
description: 'The tag to use for the container image'
14+
required: false
15+
type: string
16+
jobs:
17+
publish_github:
18+
name: Publish the container image to GitHub Container Registry
19+
runs-on: ubuntu-latest
20+
strategy:
21+
# Go hard on the builders
22+
max-parallel: 5
23+
matrix:
24+
alpine-version: ['3.20']
25+
ruby-version: ['3.4.1']
26+
steps:
27+
-
28+
name: Checkout repository
29+
uses: actions/checkout@v4
30+
-
31+
name: Publish to ghcr.io
32+
env:
33+
ALPINE_VERSION: ${{ matrix.alpine-version }}
34+
REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
RUBY_VERSION: ${{ matrix.ruby-version }}
36+
TAG: ${{ github.event.inputs.tag || '' }}
37+
TRACE: ${{ secrets.ACTIONS_STEP_DEBUG || 'false' }}
38+
# yamllint disable rule:line-length
39+
run: |
40+
if [ -z "$TAG" ]
41+
then
42+
[ "$TRACE" = true ] && printf 'No tag provided, getting tag from .version.txt\n' >&2
43+
if [ -f ".version.txt" ]
44+
then
45+
version=$(<.version.txt)
46+
else
47+
[ "$TRACE" = true ] && printf 'No .version.txt found, getting version from git describe --tags --abbrev=0\n' >&2
48+
version=$(git describe --tags --abbrev=0)
49+
fi
50+
else
51+
[ "$TRACE" = true ] && printf 'Using provided tag %s\n' "$TAG" >&2
52+
version=$TAG
53+
fi
54+
[ "$TRACE" = 'true' ] && printf 'Calling ./ci/build_image.sh -vvp "%s"\n' "$version" >&2
55+
IMAGE_NAME=$(basename "$GITHUB_REPOSITORY") \
56+
GITHUB_TOKEN=$REGISTRY_TOKEN \
57+
ALPINE_VERSION=$ALPINE_VERSION \
58+
RUBY_VERSION=$RUBY_VERSION \
59+
./ci/build_image.sh -vvp "$version"
60+
# yamllint enable rule:line-length
61+
shell: bash
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
name: Conventional Commits And PR titles
3+
4+
on: # yamllint disable-line rule:truthy
5+
pull_request_target:
6+
types:
7+
- opened
8+
- edited
9+
- synchronize
10+
11+
jobs:
12+
comventional_commits:
13+
name: Validate Commit Subjects
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: webiny/action-conventional-commits@v1.3.0
18+
name: Validate Commit Subjects
19+
with:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
# All of the Angular commit types are allowed by default.
22+
# Added types to this:
23+
# * eyes - For observability related changes
24+
# * sec - For security related changes
25+
allowed-commit-types: "build,chore,ci,docs,eyes,feat,fix,perf,refactor,revert,sec,style,test" # yamllint disable-line rule:line-length
26+
conventional_pr_title:
27+
name: Validate PR title
28+
runs-on: ubuntu-latest
29+
steps:
30+
-
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
id: validate-pr-title
34+
name: Validate PR title
35+
uses: amannn/action-semantic-pull-request@v5
36+
with:
37+
# All of the Angular commit types are allowed by default.
38+
# Added types to this:
39+
# * eyes - For observability related changes
40+
# * sec - For security related changes
41+
types: |
42+
build
43+
chore
44+
ci
45+
docs
46+
eyes
47+
feat
48+
fix
49+
perf
50+
refactor
51+
revert
52+
sec
53+
style
54+
test
55+
# We don't enforce scopes
56+
# scopes:
57+
# - frontend
58+
# - backend
59+
# - ci
60+
# We don't disallow any scopes
61+
# disallowScopes: |
62+
# release
63+
wip: true

.github/workflows/gem.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
name: Publish Ruby Gem
3+
on: # yamllint disable-line rule:truthy
4+
workflow_call:
5+
workflow_dispatch:
6+
jobs:
7+
publish_gem:
8+
name: Publish the gem to registries
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
registry:
13+
- key: rubygems
14+
secret: RUBYGEMS_TOKEN
15+
steps:
16+
-
17+
name: Checkout repository
18+
uses: actions/checkout@v4
19+
-
20+
name: Set up Ruby
21+
uses: ruby/setup-ruby@v1
22+
with:
23+
ruby-version: 3.4.1
24+
bundler-cache: false
25+
-
26+
name: Publish to ${{ matrix.registry }}
27+
env:
28+
TRACE: ${{ secrets.ACTIONS_STEP_DEBUG || 'false' }}
29+
GEM_TOKEN: ${{ secrets[matrix.registry.secret] }}
30+
REGISTRY: ${{ matrix.registry.key }}
31+
run: |
32+
bundle install
33+
TRACE="$TRACE" GEM_TOKEN="$GEM_TOKEN" ./ci/publish-gem.sh "$REGISTRY"
34+
shell: bash

.github/workflows/main.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Ruby
2+
3+
on:
4+
workflow_call:
5+
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
name: Ruby ${{ matrix.ruby }}
12+
strategy:
13+
matrix:
14+
ruby:
15+
- '3.4.5'
16+
services:
17+
nats:
18+
image: nats:latest
19+
ports: ["4222:4222", "6222:6222", "8222:8222"]
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Set up Ruby
23+
uses: ruby/setup-ruby@v1
24+
with:
25+
ruby-version: ${{ matrix.ruby }}
26+
bundler-cache: false
27+
- name: Install dependencies
28+
run: bundle install --jobs 4 --retry 3
29+
- name: Run the default task
30+
run: bundle exec rake
31+
env:
32+
NATS_URI: nats://nats:4222

.github/workflows/publish.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Publish
3+
4+
on: # yamllint disable-line rule:truthy
5+
workflow_dispatch:
6+
workflow_call:
7+
8+
jobs:
9+
gem:
10+
name: Build and publish gem
11+
uses: ./.github/workflows/gem.yaml
12+
secrets: inherit
13+
14+
# containers:
15+
# name: Build and publish OCI container images
16+
# uses: ./.github/workflows/container.yaml
17+
# secrets: inherit

.github/workflows/release.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
name: Release
3+
4+
on: # yamllint disable-line rule:truthy
5+
push:
6+
branches:
7+
- main
8+
workflow_dispatch:
9+
workflow_call:
10+
11+
jobs:
12+
validate:
13+
name: Validations
14+
uses: ./.github/workflows/validations.yaml
15+
16+
release:
17+
needs: [validate]
18+
name: Create a release
19+
runs-on: ubuntu-latest
20+
outputs:
21+
release_created: ${{ steps.release.outputs.release_created }}
22+
steps:
23+
-
24+
uses: actions/checkout@v4
25+
id: git-checkout
26+
with:
27+
fetch-tags: true
28+
-
29+
uses: googleapis/release-please-action@v4
30+
id: release
31+
with:
32+
config-file: .release-please-config.json
33+
manifest-file: .release-please-manifest.json
34+
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
35+
-
36+
id: debug
37+
env:
38+
RELEASE_CREATED: ${{ steps.release.outputs.release_created }}
39+
TRACE: ${{ secrets.ACTIONS_STEP_DEBUG || 'false' }}
40+
run: |
41+
if [ "$TRACE" != 'false' ]
42+
then
43+
printf 'Release created: %s\n' "$RELEASE_CREATED"
44+
fi
45+
46+
publish:
47+
if: needs.release.outputs.release_created
48+
needs: release
49+
name: Build and publish artifacts
50+
uses: ./.github/workflows/publish.yaml
51+
secrets: inherit

.github/workflows/validations.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
name: Validations
3+
4+
on: # yamllint disable-line rule:truthy
5+
workflow_dispatch:
6+
workflow_call:
7+
pull_request:
8+
9+
jobs:
10+
validate_ruby:
11+
name: Ruby Tests
12+
uses: ./.github/workflows/main.yaml

.release-please-config.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"packages": {
3+
".": {
4+
"changelog-path": "CHANGELOG.md",
5+
"release-type": "simple",
6+
"bump-minor-pre-major": true,
7+
"bump-patch-for-minor-pre-major": true,
8+
"draft": false,
9+
"prerelease": false,
10+
"version-file": ".version.txt",
11+
"extra-files": [
12+
{
13+
"type": "generic",
14+
"path": "lib/sequel/pgt_outbox/version.rb"
15+
},
16+
{
17+
"type": "generic",
18+
"path": "oci/Gemfile"
19+
}
20+
],
21+
"exclude-paths": [
22+
".release-please-manifest.json",
23+
".version.txt",
24+
"lib/sequel/pgt_outbox/version.rb",
25+
".rubocop.yml",
26+
".overcommit.yml",
27+
"coverage/coverage.json"
28+
]
29+
}
30+
},
31+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
32+
}

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "0.2.7"
3+
}

.rubocop.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
plugins:
2+
- rubocop-performance
3+
- rubocop-rake
4+
- rubocop-minitest
5+
6+
AllCops:
7+
NewCops: enable
8+
9+
Layout/LineLength:
10+
Max: 140
11+
12+
Metrics/BlockLength:
13+
Exclude:
14+
- 'spec/**/*.rb'
15+
16+
Layout/ArgumentAlignment:
17+
EnforcedStyle: with_fixed_indentation
18+
19+
Bundler/OrderedGems:
20+
TreatCommentsAsGroupSeparators: true
21+
22+
Layout/MultilineMethodCallIndentation:
23+
EnforcedStyle: indented
24+
25+
Layout/ArrayAlignment:
26+
EnforcedStyle: with_fixed_indentation
27+
28+
Style/Documentation:
29+
Enabled: false
30+
31+
Style/FrozenStringLiteralComment:
32+
Enabled: true
33+
SafeAutoCorrect: true
34+
35+
Style/TrailingCommaInArguments:
36+
EnforcedStyleForMultiline: comma
37+
38+
Style/TrailingCommaInArrayLiteral:
39+
EnforcedStyleForMultiline: comma
40+
41+
Style/TrailingCommaInHashLiteral:
42+
EnforcedStyleForMultiline: comma
43+
44+
Style/HashSyntax:
45+
Enabled: true
46+
EnforcedShorthandSyntax: always

0 commit comments

Comments
 (0)