Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
razor-x committed Apr 18, 2024
0 parents commit 1d877fa
Show file tree
Hide file tree
Showing 29 changed files with 1,032 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ARG VARIANT="3"

FROM mcr.microsoft.com/vscode/devcontainers/ruby:${VARIANT}

USER vscode
WORKDIR /home/vscode

RUN mkdir -p .config/git \
&& echo ".vscode/*" >> .config/git/ignore \
&& echo "*.code-workspace" >> .config/git/ignore \
&& echo ".history/" >> .config/git/ignore
18 changes: 18 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainer.schema.json",
"name": "Ruby",
"build": {
"dockerfile": "Dockerfile",
"args": {
"VARIANT": "3"
}
},
"extensions": [
"rebornix.Ruby",
"ms-vsliveshare.vsliveshare",
"EditorConfig.EditorConfig",
"esbenp.prettier-vscode"
],
"postCreateCommand": "bundle install",
"remoteUser": "vscode"
}
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2
34 changes: 34 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: Setup
description: Setup Ruby and install dependencies.

inputs:
ruby_version:
description: The Ruby version.
required: false
default: '3.3.0'
install_dependencies:
description: Install dependencies.
required: false
default: 'true'
gem_credentials:
description: Gem credentials.
required: false

runs:
using: composite
steps:
- name: Setup credentials
if: inputs.gem_credentials
shell: bash
run: |
mkdir -p ~/.gem
echo "$GEM_CREDENTIALS" > ~/.gem/credentials
chmod 600 ~/.gem/credentials
env:
GEM_CREDENTIALS: ${{ inputs.gem_credentials }}
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: ${{ inputs.install_dependencies == 'true' }}
ruby-version: ${{ inputs.ruby_version }}
36 changes: 36 additions & 0 deletions .github/workflows/_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: _build

on:
workflow_call:
inputs:
ruby_version:
description: The Ruby version.
type: string
required: false
default: '3.3.0'
outputs:
artifact_name:
description: The artifact name.
value: build-${{ github.sha }}

jobs:
build:
name: Gem
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
with:
ruby_version: ${{ inputs.ruby_version }}
- name: Build
run: bundle exec rake build
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: build-${{ github.sha }}
if-no-files-found: error
path: pkg/
47 changes: 47 additions & 0 deletions .github/workflows/_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: _publish

on:
workflow_call:
inputs:
artifact_name:
description: The artifact name.
type: string
required: true
registry_key:
description: The gem registry credentials key.
type: string
required: true
registry_host:
description: The gem registry host.
type: string
required: true
secrets:
registry_credentials:
description: The gem registry credentials.
required: true

jobs:
publish:
name: Publish gem
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
with:
install_dependencies: 'false'
gem_credentials: ':${{ inputs.registry_key }}: ${{ secrets.registry_credentials }}'
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact_name }}
path: pkg/
- name: Publish
run: gem push --key $REGISTRY_KEY --host $REGISTRY_HOST $GEM_ARTIFACTS/*
env:
REGISTRY_KEY: ${{ inputs.registry_key }}
REGISTRY_HOST: ${{ inputs.registry_host }}
GEM_ARTIFACTS: pkg
115 changes: 115 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
---
name: Check

on:
push:
branches:
- main
pull_request:
branches:
- '**'

jobs:
test:
name: Test (Ruby ${{ matrix.ruby }} on ${{ matrix.os_name }})
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
ruby:
- '3.1'
- '3.2'
- '3.3'
include:
- os: ubuntu-latest
os_name: Linux
- os: macos-latest
os_name: macOS
- os: windows-latest
os_name: Windows
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
with:
ruby_version: ${{ matrix.ruby }}
- name: Test
run: bundle exec rake test
lint:
name: Lint (Ruby ${{ matrix.ruby }})
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
ruby:
- '3.1'
- '3.2'
- '3.3'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
with:
ruby_version: ${{ matrix.ruby }}
- name: Lint
run: bundle exec rake lint
build:
name: Build
uses: ./.github/workflows/_build.yml
install:
name: Install (Ruby ${{ matrix.ruby }} on ${{ matrix.os_name }})
runs-on: ${{ matrix.os }}
timeout-minutes: 30
needs: build
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
ruby:
- '3.1'
- '3.2'
- '3.3'
include:
- os: ubuntu-latest
os_name: Linux
- os: macos-latest
os_name: macOS
- os: windows-latest
os_name: Windows
steps:
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ needs.build.outputs.artifact_name }}
path: .
- name: Find gems
uses: tj-actions/glob@v21
id: gems
with:
files: '*.gem'
- name: Create main.rb
uses: DamianReeves/[email protected]
with:
write-mode: overwrite
path: main.rb
contents: |
require 'seam'
- name: Install
run: gem install ${{ steps.gems.outputs.paths }}
- name: Run
run: ruby main.rb
41 changes: 41 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
name: Format

on:
push:
branches-ignore:
- main
workflow_dispatch: {}

jobs:
commit:
name: Format code
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.GH_TOKEN }}
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
git_user_signingkey: true
git_commit_gpgsign: true
git_committer_name: ${{ secrets.GIT_USER_NAME }}
git_committer_email: ${{ secrets.GIT_USER_EMAIL }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Setup
uses: ./.github/actions/setup
- name: Format
run: bundle exec rake format
- name: Commit
uses: stefanzweifel/git-auto-commit-action@v5
if: always()
with:
commit_message: 'ci: Format code'
commit_user_name: ${{ secrets.GIT_USER_NAME }}
commit_user_email: ${{ secrets.GIT_USER_EMAIL }}
commit_author: ${{ secrets.GIT_USER_NAME }} <${{ secrets.GIT_USER_EMAIL }}>
42 changes: 42 additions & 0 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: Generate

on:
push:
branches-ignore:
- main
workflow_dispatch: {}

jobs:
commit:
name: Generate code
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.GH_TOKEN }}
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
git_user_signingkey: true
git_commit_gpgsign: true
git_committer_name: ${{ secrets.GIT_USER_NAME }}
git_committer_email: ${{ secrets.GIT_USER_EMAIL }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Setup
uses: ./.github/actions/setup
with:
install_dependencies: 'false'
- name: Normalize Gemfile.lock
run: bundle install
- name: Commit
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'ci: Generate code'
commit_user_name: ${{ secrets.GIT_USER_NAME }}
commit_user_email: ${{ secrets.GIT_USER_EMAIL }}
commit_author: ${{ secrets.GIT_USER_NAME }} <${{ secrets.GIT_USER_EMAIL }}>
Loading

0 comments on commit 1d877fa

Please sign in to comment.