-
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.
Merge pull request #122 from unboxed/update-github-action
Update GitHub action
- Loading branch information
Showing
8 changed files
with
194 additions
and
169 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
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,73 @@ | ||
--- | ||
name: Verify | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
bundler-audit: | ||
type: boolean | ||
default: false | ||
brakeman: | ||
type: boolean | ||
default: false | ||
rubocop: | ||
type: boolean | ||
default: false | ||
language-versions: | ||
type: boolean | ||
default: false | ||
|
||
jobs: | ||
linters: | ||
name: Linters | ||
runs-on: ubuntu-latest | ||
env: | ||
BUNDLE_WITHOUT: development | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Ruby and install gems | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
bundler-cache: true | ||
|
||
- name: Check bundle for known CVEs | ||
if: ${{ inputs.bundler-audit == true }} | ||
run: | | ||
bundle exec bundler-audit | ||
- name: Analyse code for vulnerabilities | ||
if: ${{ inputs.brakeman == true }} | ||
run: | | ||
bundle exec brakeman | ||
- name: Analyse code for formatting | ||
if: ${{ inputs.rubocop == true }} | ||
run: | | ||
${{ inputs.run-before-linters }} | ||
bundle exec rubocop | ||
- name: Ensure language versions match | ||
if: ${{ inputs.language-versions == true }} | ||
run: | | ||
NODE_VERSION=$(cat .node-version) | ||
if ! grep -q "^ARG NODE_VERSION=$NODE_VERSION" Dockerfile; then | ||
echo "Dockerfile has wrong node: $(grep '^ARG NODE_VERSION' Dockerfile)" >&2 | ||
exit 1 | ||
fi | ||
if ! grep -q "^ARG NODE_VERSION=$NODE_VERSION" Dockerfile.production; then | ||
echo "Dockerfile.production has wrong node: $(grep '^ARG NODE_VERSION' Dockerfile.production)" >&2 | ||
exit 1 | ||
fi | ||
RUBY_VERSION=$(cat .ruby-version) | ||
if ! grep -q "^ARG RUBY_VERSION=$RUBY_VERSION" Dockerfile; then | ||
echo "Dockerfile has wrong ruby: $(grep '^ARG RUBY_VERSION' Dockerfile)" >&2 | ||
exit 1 | ||
fi | ||
if ! grep -q "^ARG RUBY_VERSION=$RUBY_VERSION" Dockerfile.production; then | ||
echo "Dockerfile.production has wrong ruby: $(grep '^ARG RUBY_VERSION' Dockerfile.production)" >&2 | ||
exit 1 | ||
fi |
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,81 @@ | ||
--- | ||
name: Testing | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
exclude: | ||
type: string | ||
required: false | ||
default: "" | ||
include: | ||
type: string | ||
required: false | ||
default: "spec/**/*_spec.rb" | ||
name: | ||
type: string | ||
required: true | ||
ruby-version: | ||
type: string | ||
default: "3.2.2" | ||
|
||
jobs: | ||
tests: | ||
name: ${{ inputs.name }} | ||
runs-on: ubuntu-latest | ||
|
||
services: | ||
postgres: | ||
image: postgres | ||
ports: ["5432:5432"] | ||
env: | ||
POSTGRES_PASSWORD: postgres | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Ruby ${{ inputs.ruby-version }} and install gems | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: ${{ inputs.ruby-version }} | ||
bundler-cache: true | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
if: hashFiles('yarn.lock') != '' | ||
with: | ||
node-version-file: .node-version | ||
cache: "yarn" | ||
|
||
- name: Install packages | ||
run: | | ||
yarn install --frozen-lockfile | ||
- name: Install postgres client | ||
shell: bash | ||
run: | | ||
sudo apt-get -yqq install libpq-dev | ||
- name: Setup test database | ||
env: | ||
DATABASE_URL: postgres://postgres:postgres@localhost:5432/test | ||
RAILS_ENV: test | ||
run: | | ||
bundle exec rails db:create db:schema:load | ||
- name: Assets precompile | ||
run: bundle exec rake assets:precompile --trace | ||
|
||
- name: Run specs | ||
env: | ||
DATABASE_URL: postgres://postgres:postgres@localhost:5432/test | ||
RAILS_ENV: test | ||
SPEC_OPTS: '-f doc --exclude "${{ inputs.exclude }}" --pattern "${{ inputs.include }}"' | ||
run: | | ||
bundle exec rake spec |
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
Oops, something went wrong.