This repository has been archived by the owner on May 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a9ff733
Showing
125 changed files
with
3,570 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
defaults |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export DATABASE_URL="postgresql://postgres:password@localhost:5432/template_development?schema=public&connection_limit=5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
EnableDefaultLinters: true | ||
linters: | ||
ErbSafety: | ||
enabled: true | ||
Rubocop: | ||
enabled: true | ||
rubocop_config: | ||
inherit_from: | ||
- .rubocop.yml | ||
Layout/InitialIndentation: | ||
Enabled: false | ||
Layout/LineLength: | ||
Enabled: false | ||
Layout/TrailingEmptyLines: | ||
Enabled: false | ||
Layout/TrailingWhitespace: | ||
Enabled: false | ||
Naming/FileName: | ||
Enabled: false | ||
Style/FrozenStringLiteralComment: | ||
Enabled: false | ||
Lint/UselessAssignment: | ||
Enabled: false | ||
Rails/OutputSafety: | ||
Enabled: false | ||
GitHub/RailsViewRenderPathsExist: | ||
Enabled: false | ||
Layout/FirstArgumentIndentation: | ||
Enabled: false | ||
SpaceInHtmlTag: | ||
enabled: false | ||
PartialInstanceVariable: | ||
enabled: true | ||
RequireScriptNonce: | ||
enabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# See https://git-scm.com/docs/gitattributes for more about git attribute files. | ||
|
||
# Mark the database schema as having been generated. | ||
db/schema.rb linguist-generated | ||
|
||
# Mark any vendored files as having been vendored. | ||
vendor/* linguist-vendored |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: 'Run erb-lint with reviewdog' | ||
description: '🐶 Run erb-lint with reviewdog on pull requests to improve code review experience.' | ||
inputs: | ||
github_token: | ||
description: 'GITHUB_TOKEN' | ||
default: ${{ github.token }} | ||
erblint_version: | ||
description: 'erb-lint version' | ||
rubocop_extensions: | ||
description: 'Rubocop extensions' | ||
default: 'rubocop-rails rubocop-performance rubocop-rspec rubocop-i18n rubocop-rake' | ||
use_bundler: | ||
description: "Run erb-lint with bundle exec. Default: `false`" | ||
default: 'false' | ||
tool_name: | ||
description: 'Tool name to use for reviewdog reporter' | ||
default: 'erb-lint' | ||
level: | ||
description: 'Report level for reviewdog [info,warning,error]' | ||
default: 'error' | ||
reporter: | ||
description: | | ||
Reporter of reviewdog command [github-pr-check,github-check,github-pr-review]. | ||
Default is github-pr-check. | ||
default: 'github-pr-check' | ||
filter_mode: | ||
description: | | ||
Filtering mode for the reviewdog command [added,diff_context,file,nofilter]. | ||
Default is added. | ||
default: 'added' | ||
reviewdog_flags: | ||
description: 'Additional reviewdog flags' | ||
default: '' | ||
workdir: | ||
description: "The directory from which to look for and run erb-lint. Default '.'" | ||
default: '.' | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Get changed files | ||
id: changed-files | ||
uses: tj-actions/[email protected] | ||
with: | ||
files: | | ||
**/*.erb | ||
- run: .github/actions/erblint/script.sh | ||
shell: sh | ||
env: | ||
REVIEWDOG_VERSION: v0.14.1 | ||
INPUT_GITHUB_TOKEN: ${{ inputs.github_token }} | ||
INPUT_RUBOCOP_EXTENSIONS: ${{ inputs.rubocop_extensions }} | ||
INPUT_ERBLINT_VERSION: ${{ inputs.erblint_version }} | ||
INPUT_FILES: ${{ steps.changed-files.outputs.all_changed_files }} | ||
INPUT_TOOL_NAME: ${{ inputs.tool_name }} | ||
INPUT_LEVEL: ${{ inputs.level }} | ||
INPUT_REPORTER: ${{ inputs.reporter }} | ||
INPUT_FILTER_MODE: ${{ inputs.filter_mode }} | ||
INPUT_REVIEWDOG_FLAGS: ${{ inputs.reviewdog_flags }} | ||
INPUT_WORKDIR: ${{ inputs.workdir }} | ||
INPUT_USE_BUNDLER: ${{ inputs.use_bundler }} | ||
branding: | ||
icon: 'check-circle' | ||
color: 'blue' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#!/bin/sh -e | ||
version() { | ||
if [ -n "$1" ]; then | ||
echo "-v $1" | ||
fi | ||
} | ||
|
||
cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit | ||
export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" | ||
|
||
TEMP_PATH="$(mktemp -d)" | ||
PATH="${TEMP_PATH}:$PATH" | ||
|
||
echo '::group::🐶 Installing reviewdog ... https://github.com/reviewdog/reviewdog' | ||
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b "${TEMP_PATH}" "${REVIEWDOG_VERSION}" 2>&1 | ||
echo '::endgroup::' | ||
|
||
echo '::group:: Installing erb-lint ... https://github.com/Shopify/erb-lint' | ||
# grep for erb-lint version | ||
ERBLINT_GEMFILE_VERSION=$(ruby -ne 'print $& if /^\s{4}erb_lint\s\(\K.*(?=\))/' Gemfile.lock) | ||
|
||
# if erb-lint version found, then pass it to the gem install | ||
# left it empty otherwise, so no version will be passed | ||
if [ -n "$ERBLINT_GEMFILE_VERSION" ]; then | ||
ERBLINT_VERSION=$ERBLINT_GEMFILE_VERSION | ||
else | ||
printf "Cannot get the erb-lint's version from Gemfile.lock. The latest version will be installed." | ||
fi | ||
echo '::endgroup::' | ||
|
||
gem install -N erb_lint --version "${ERBLINT_VERSION}" | ||
|
||
echo '::group:: Installing rubocop extensions' | ||
# Traverse over list of rubocop extensions | ||
for extension in $INPUT_RUBOCOP_EXTENSIONS; do | ||
# grep for name and version | ||
INPUT_RUBOCOP_EXTENSION_NAME=$(echo "$extension" |awk 'BEGIN { FS = ":" } ; { print $1 }') | ||
INPUT_RUBOCOP_EXTENSION_VERSION=$(echo "$extension" |awk 'BEGIN { FS = ":" } ; { print $2 }') | ||
|
||
|
||
# if version is 'gemfile' | ||
if [ "${INPUT_RUBOCOP_EXTENSION_VERSION}" = "gemfile" ]; then | ||
# if Gemfile.lock is here | ||
if [ -f 'Gemfile.lock' ]; then | ||
# grep for rubocop extension version | ||
RUBOCOP_EXTENSION_GEMFILE_VERSION=$(ruby -ne "print $& if /^\s{4}$INPUT_RUBOCOP_EXTENSION_NAME\s\(\K.*(?=\))/" Gemfile.lock) | ||
|
||
|
||
# if rubocop extension version found, then pass it to the gem install | ||
# left it empty otherwise, so no version will be passed | ||
if [ -n "$RUBOCOP_EXTENSION_GEMFILE_VERSION" ]; then | ||
RUBOCOP_EXTENSION_VERSION=$RUBOCOP_EXTENSION_GEMFILE_VERSION | ||
else | ||
printf "Cannot get the rubocop extension version from Gemfile.lock. The latest version will be installed." | ||
fi | ||
else | ||
printf 'Gemfile.lock not found. The latest version will be installed.' | ||
fi | ||
else | ||
# set desired rubocop extension version | ||
RUBOCOP_EXTENSION_VERSION=$INPUT_RUBOCOP_EXTENSION_VERSION | ||
fi | ||
|
||
# Handle extensions with no version qualifier | ||
if [ -z "${RUBOCOP_EXTENSION_VERSION}" ]; then | ||
unset RUBOCOP_EXTENSION_VERSION_FLAG | ||
else | ||
RUBOCOP_EXTENSION_VERSION_FLAG="--version ${RUBOCOP_EXTENSION_VERSION}" | ||
fi | ||
|
||
# shellcheck disable=SC2086 | ||
gem install -N "${INPUT_RUBOCOP_EXTENSION_NAME}" ${RUBOCOP_EXTENSION_VERSION_FLAG} | ||
done | ||
echo '::endgroup::' | ||
|
||
export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" | ||
|
||
if [ "${INPUT_USE_BUNDLER}" = "false" ]; then | ||
BUNDLE_EXEC="" | ||
else | ||
BUNDLE_EXEC="bundle exec " | ||
fi | ||
|
||
echo '::group:: Running erb-lint with reviewdog 🐶 ...' | ||
# shellcheck disable=SC2086 | ||
${BUNDLE_EXEC}erblint --format compact ${INPUT_FILES} \ | ||
| reviewdog \ | ||
-efm="%f:%l:%c: %m" \ | ||
-name="${INPUT_TOOL_NAME}" \ | ||
-reporter="${INPUT_REPORTER}" \ | ||
-filter-mode="${INPUT_FILTER_MODE}" \ | ||
-level="${INPUT_LEVEL}" \ | ||
${INPUT_REVIEWDOG_FLAGS} | ||
|
||
reviewdog_rc=$? | ||
echo '::endgroup::' | ||
exit $reviewdog_rc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: static analysis (legacy) | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- main | ||
workflow_dispatch: | ||
repository_dispatch: | ||
|
||
jobs: | ||
scan: | ||
uses: ibm-skills-network/.github/.github/workflows/appscan-legacy.yml@main | ||
secrets: | ||
skills-network-bot-app-id: ${{ secrets.SKILLS_NETWORK_BOT_APP_ID }} | ||
skills-network-bot-private-key: ${{ secrets.SKILLS_NETWORK_BOT_PRIVATE_KEY }} | ||
asoc-key: ${{ secrets.ASOC_KEY }} | ||
asoc-secret: ${{ secrets.ASOC_SECRET }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Lint | ||
on: [pull_request] | ||
jobs: | ||
lint: | ||
name: Rubocop | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
- uses: ruby/setup-ruby@v1 | ||
- name: rubocop | ||
uses: reviewdog/action-rubocop@v2 | ||
with: | ||
rubocop_version: gemfile | ||
rubocop_extensions: rubocop-performance:gemfile rubocop-rails:gemfile rubocop-github:gemfile rubocop-rspec:gemfile | ||
# erb-lint has issues with Alpine (of which is used extensively throughout our products), follow the following issues before re-enabling: | ||
# https://github.com/Shopify/erb-lint/issues/221 | ||
# https://github.com/Shopify/better-html/issues/69 | ||
# - name: erb-lint | ||
# uses: ./.github/actions/erblint | ||
# with: | ||
# rubocop_extensions: rubocop-performance:gemfile rubocop-rails:gemfile rubocop-github:gemfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: mirror github ibm | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- main | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# Allows you to use the GitHub API to trigger a webhook event | ||
repository_dispatch: | ||
|
||
jobs: | ||
mirror: | ||
uses: ibm-skills-network/.github/.github/workflows/mirror-github-ibm.yml@main | ||
with: | ||
repo_name: rails-app-template | ||
secrets: | ||
ssh_private_key: | ||
${{ secrets.MIRROR_GITHUB_IBM_SSH_PRIVATE_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Build and Release Image | ||
on: | ||
push: | ||
branches: | ||
- master | ||
- main | ||
tags: | ||
- '**' | ||
schedule: | ||
- cron: 0 5 * * * | ||
workflow_dispatch: | ||
inputs: | ||
suffix: | ||
description: Custom suffix for tag | ||
required: false | ||
repository_dispatch: | ||
jobs: | ||
build: | ||
uses: ibm-skills-network/.github/.github/workflows/release.yml@main | ||
with: | ||
image: icr.io/skills-network-faculty/rails-app-template | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Tests | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
name: RSpec | ||
runs-on: ubuntu-latest | ||
|
||
services: | ||
postgres: | ||
image: postgres:14-alpine | ||
ports: ["5432:5432"] | ||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: password | ||
POSTGRES_DB: rails_app_template_test | ||
redis: | ||
image: redis:7-alpine | ||
ports: ["6379:6379"] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
bundler-cache: true | ||
- name: Setup Database | ||
env: | ||
RAILS_ENV: test | ||
run: bin/rails db:create db:schema:load | ||
- name: Test with rspec | ||
env: | ||
RAILS_ENV: test | ||
run: bundle exec rspec spec | ||
- name: Archive RSpec screenshots | ||
if: always() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: rspec-screenshots | ||
path: tmp/screenshots |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake | ||
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby | ||
|
||
name: static analysis | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
workflow_dispatch: | ||
|
||
jobs: | ||
scan: | ||
uses: ibm-skills-network/.github/.github/workflows/static-analysis.yml@main | ||
secrets: | ||
skills-network-bot-app-id: ${{ secrets.SKILLS_NETWORK_BOT_APP_ID }} | ||
skills-network-bot-private-key: ${{ secrets.SKILLS_NETWORK_BOT_PRIVATE_KEY }} | ||
asoc-key: ${{ secrets.ASOC_KEY }} | ||
asoc-secret: ${{ secrets.ASOC_SECRET }} |
Oops, something went wrong.