Skip to content

Commit

Permalink
chore: add ci/cd configuration (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthv authored Sep 5, 2023
1 parent dce11f7 commit a0907d8
Show file tree
Hide file tree
Showing 62 changed files with 5,525 additions and 212 deletions.
3 changes: 3 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins:
rubocop:
enabled: true
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Expected behavior

TODO: Please describe here the behavior you are expecting.

## Actual behavior

TODO: What is the current behavior?

## Failure Logs

TODO: Please include any relevant log snippets, if necessary.

## Context

TODO: Please provide any relevant information about your setup.

* Package Version:
* PHP Version:
11 changes: 11 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Definition of Done

### General

- [ ] Write an explicit title for the Pull Request, following [Conventional Commits specification](https://www.conventionalcommits.org)
- [ ] Test manually the implemented changes
- [ ] Validate the code quality (indentation, syntax, style, simplicity, readability)

### Security

- [ ] Consider the security impact of the changes made
138 changes: 138 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: Lint, Test, Coverage and Deploy

on:
push:
branches:
- main
- beta
pull_request:

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['3.0', '3.1', '3.2']
package:
- forestadmin_agent
- forestadmin_rails

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1
with:
ruby-version: ${{ matrix.ruby-version }}

- name: Install dependencies on main repo
run: |
gem install bundler
bundle install
- name: Install dependencies on agent package
working-directory: ./packages/forestadmin_agent
run: bundle install

- name: Install dependencies on plugin rails package
working-directory: ./packages/forestadmin_rails
run: bundle install

- name: Run RuboCop
run: bundle exec rubocop

test:
name: Test
runs-on: ubuntu-latest
needs: [lint]
strategy:
matrix:
ruby-version: ['3.0', '3.1', '3.2']
package:
- forestadmin_agent
- forestadmin_rails
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1
with:
ruby-version: ${{ matrix.ruby-version }}

- name: Install dependencies on main repo
run: |
gem install bundler
bundle install
- name: Test
run: cd packages/${{ matrix.package }} && bundle install && bundle exec rspec --color --format doc && cd -

- name: Upload coverage
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.package }}
path: packages/${{ matrix.package }}/coverage/*
retention-days: 1

coverage:
name: Coverage
runs-on: ubuntu-latest
needs: [test]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download coverage reports
uses: actions/download-artifact@v3
with:
path: reports

- name: Send coverage
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageLocations: |
${{github.workspace}}/reports/forestadmin_agent/coverage.json:simplecov
# ${{github.workspace}}/reports/forestadmin_rails/coverage.json:simplecov
debug: true

deploy:
name: Release package
runs-on: ubuntu-latest
needs: [coverage]
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false # GITHUB_TOKEN must not be set for the semantic release

- uses: actions/setup-node@v3
with:
node-version: 18.14.0

- uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Install semantic release dependencies
run: yarn

- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
id: semantic
with:
semantic_version: 17.3.0
env:
GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.GIT_COMMITTER_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.GIT_COMMITTER_NAME }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# IDE
/.idea
/.vscode
.DS_Store
*.iml

# RSPEC
.rspec_status
coverage/

# npm
node_modules

# composer
vendor

# GEM
Gemfile.lock
*.gem
pkg/
27 changes: 27 additions & 0 deletions .overcommit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
CommitMsg:
MessageFormat:
enabled: true
description: 'Check commit message matches expected pattern'
pattern: '^(?<type>build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(?<scope>\(\w+\)?((?=:\s)|(?=!:\s)))?(?<breaking>!)?(?<subject>:\s.*)'
expected_pattern_message: '<type>(<scope>): <subject>'
sample_message: 'feat(datasource): add onboarding flow'

PreCommit:
RuboCop:
enabled: true
on_warn: fail

TrailingWhitespace:
enabled: true

BundleOutdated:
enabled: true

BundleAudit:
enabled: true

PrePush:
RSpec:
enabled: true
command: ["run_rspec"]
quiet: false
83 changes: 83 additions & 0 deletions .releaserc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
module.exports = {
branches: ['main', {name: 'beta', prerelease: true}],
plugins: [
[
'@semantic-release/commit-analyzer', {
preset: 'angular',
releaseRules: [
// Example: `type(scope): subject [force release]`
{ subject: '*\\[force release\\]*', release: 'patch' },
],
},
],
'@semantic-release/release-notes-generator',
'@semantic-release/changelog',
[
'@semantic-release/exec',
{
prepareCmd:
'sed -i \'s/VERSION = ".*"/VERSION = "${nextRelease.version}"/g\' lib/agent_ruby/version.rb; ' +
'sed -i \'s/"version": ".*"/"version": "${nextRelease.version}"/g\' package.json; ' +
'sed -i \'s/VERSION = ".*"/VERSION = "${nextRelease.version}"/g\' packages/forestadmin_agent/lib/forestadmin_agent/version.rb; ' +
'sed -i \'s/VERSION = ".*"/VERSION = "${nextRelease.version}"/g\' packages/forestadmin_rails/lib/forestadmin_rails/version.rb; ',
successCmd:
'mkdir -p $HOME/.gem '+
'touch $HOME/.gem/credentials '+
'chmod 0600 $HOME/.gem/credentials '+
'printf -- "---\n:rubygems_api_key: ${env.GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials '+
'( cd packages/forestadmin_agent && gem build && gem push forestadmin_agent-${nextRelease.version}.gem )' +
'( cd packages/forestadmin_rails && gem build && gem push forestadmin_rails-${nextRelease.version}.gem )' ,
},
],
[
'@semantic-release/git',
{
assets: [
'CHANGELOG.md',
'lib/agent_ruby/version.rb',
'packages/forestadmin_agent/lib/forestadmin_agent/version.rb',
'packages/forestadmin_rails/lib/forestadmin_rails/version.rb',
'package.json'
],
},
],
'@semantic-release/github',
'semantic-release-rubygem',
[
'semantic-release-slack-bot',
{
markdownReleaseNotes: true,
notifyOnSuccess: true,
notifyOnFail: false,
onSuccessTemplate: {
text: "📦 $package_name@$npm_package_version has been released!",
blocks: [{
type: 'section',
text: {
type: 'mrkdwn',
text: '*New `$package_name` package released!*'
}
}, {
type: 'context',
elements: [{
type: 'mrkdwn',
text: "📦 *Version:* <$repo_url/releases/tag/v$npm_package_version|$npm_package_version>"
}]
}, {
type: 'divider',
}],
attachments: [{
blocks: [{
type: 'section',
text: {
type: 'mrkdwn',
text: '*Changes* of version $release_notes',
},
}],
}],
},
packageName: 'agent_ruby',
}
],
],
}
Loading

0 comments on commit a0907d8

Please sign in to comment.