Skip to content

Commit

Permalink
Create custom Github Actions for common steps (mastodon#27518)
Browse files Browse the repository at this point in the history
  • Loading branch information
renchap authored Oct 24, 2023
1 parent 714e3ae commit 6cf9f12
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 186 deletions.
19 changes: 19 additions & 0 deletions .github/actions/setup-javascript/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'Setup Javascript'
description: 'Setup a Javascript environment ready to run the Mastodon code'
inputs:
onlyProduction:
description: Only install production dependencies
default: 'false'

runs:
using: 'composite'
steps:
- name: Set up Node.js
uses: actions/setup-node@v3
with:
cache: yarn
node-version-file: '.nvmrc'

- name: Install all yarn packages
shell: bash
run: yarn --frozen-lockfile ${{ inputs.onlyProduction != 'false' && '--production' || '' }}
23 changes: 23 additions & 0 deletions .github/actions/setup-ruby/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: 'Setup RUby'
description: 'Setup a Ruby environment ready to run the Mastodon code'
inputs:
ruby-version:
description: The Ruby version to install
default: '.ruby-version'
additional-system-dependencies:
description: 'Additional packages to install'

runs:
using: 'composite'
steps:
- name: Install system dependencies
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y libicu-dev libidn11-dev ${{ inputs.additional-system-dependencies }}
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ inputs.ruby-version }}
bundler-cache: true
10 changes: 2 additions & 8 deletions .github/workflows/bundler-audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,8 @@ jobs:
- name: Clone repository
uses: actions/checkout@v4

- name: Install native Ruby dependencies
run: sudo apt-get install -y libicu-dev libidn11-dev

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: true
- name: Set up Ruby environment
uses: ./.github/actions/setup-ruby

- name: Run bundler-audit
run: bundle exec bundler-audit
24 changes: 5 additions & 19 deletions .github/workflows/check-i18n.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,11 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libicu-dev libidn11-dev
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: true

- name: Set up Node.js
uses: actions/setup-node@v3
with:
cache: yarn
node-version-file: '.nvmrc'

- name: Install all yarn packages
run: yarn --frozen-lockfile
- name: Set up Ruby environment
uses: ./.github/actions/setup-ruby

- name: Set up Javascript environment
uses: ./.github/actions/setup-javascript

- name: Check for missing strings in English JSON
run: |
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/crowdin-download.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,8 @@ jobs:
run: sudo chown -R runner:docker .

# This is needed to run the normalize step
- name: Install native Ruby dependencies
run: sudo apt-get install -y libicu-dev libidn11-dev

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: true
- name: Set up Ruby environment
uses: ./.github/actions/setup-ruby

- name: Run i18n normalize task
run: bundle exec i18n-tasks normalize
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/lint-css.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,8 @@ jobs:
- name: Clone repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
with:
cache: yarn
node-version-file: '.nvmrc'

- name: Install all yarn packages
run: yarn --frozen-lockfile
- name: Set up Javascript environment
uses: ./.github/actions/setup-javascript

- uses: xt0rted/stylelint-problem-matcher@v1

Expand Down
12 changes: 2 additions & 10 deletions .github/workflows/lint-haml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,8 @@ jobs:
- name: Clone repository
uses: actions/checkout@v4

- name: Install native Ruby dependencies
run: |
sudo apt-get update
sudo apt-get install -y libicu-dev libidn11-dev
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: true
- name: Set up Ruby environment
uses: ./.github/actions/setup-ruby

- name: Run haml-lint
run: |
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/lint-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,8 @@ jobs:
- name: Clone repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
with:
cache: yarn
node-version-file: '.nvmrc'

- name: Install all yarn packages
run: yarn --frozen-lockfile
- name: Set up Javascript environment
uses: ./.github/actions/setup-javascript

- name: ESLint
run: yarn lint:js --max-warnings 0
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/lint-json.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,8 @@ jobs:
- name: Clone repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
with:
cache: yarn
node-version-file: '.nvmrc'

- name: Install all yarn packages
run: yarn --frozen-lockfile
- name: Set up Javascript environment
uses: ./.github/actions/setup-javascript

- name: Prettier
run: yarn lint:json
10 changes: 2 additions & 8 deletions .github/workflows/lint-md.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,8 @@ jobs:
- name: Clone repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
with:
cache: yarn
node-version-file: '.nvmrc'

- name: Install all yarn packages
run: yarn --frozen-lockfile
- name: Set up Javascript environment
uses: ./.github/actions/setup-javascript

- name: Prettier
run: yarn lint:md
10 changes: 2 additions & 8 deletions .github/workflows/lint-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,8 @@ jobs:
- name: Clone repository
uses: actions/checkout@v4

- name: Install native Ruby dependencies
run: sudo apt-get install -y libicu-dev libidn11-dev

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: true
- name: Set up Ruby environment
uses: ./.github/actions/setup-ruby

- name: Set-up RuboCop Problem Matcher
uses: r7kamura/rubocop-problem-matchers-action@v1
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/lint-yml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,8 @@ jobs:
- name: Clone repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
with:
cache: yarn
node-version-file: '.nvmrc'

- name: Install all yarn packages
run: yarn --frozen-lockfile
- name: Set up Javascript environment
uses: ./.github/actions/setup-javascript

- name: Prettier
run: yarn lint:yml
10 changes: 2 additions & 8 deletions .github/workflows/test-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,8 @@ jobs:
- name: Clone repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
with:
cache: yarn
node-version-file: '.nvmrc'

- name: Install all yarn packages
run: yarn --frozen-lockfile
- name: Set up Javascript environment
uses: ./.github/actions/setup-javascript

- name: Jest testing
run: yarn jest --reporters github-actions summary
12 changes: 2 additions & 10 deletions .github/workflows/test-migrations-one-step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,8 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install native Ruby dependencies
run: |
sudo apt-get update
sudo apt-get install -y libicu-dev libidn11-dev
- name: Set up bundler cache
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: true
- name: Set up Ruby environment
uses: ./.github/actions/setup-ruby

- name: Create database
run: './bin/rails db:create'
Expand Down
12 changes: 2 additions & 10 deletions .github/workflows/test-migrations-two-step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,8 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install native Ruby dependencies
run: |
sudo apt-get update
sudo apt-get install -y libicu-dev libidn11-dev
- name: Set up bundler cache
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: true
- name: Set up Ruby environment
uses: ./.github/actions/setup-ruby

- name: Create database
run: './bin/rails db:create'
Expand Down
Loading

0 comments on commit 6cf9f12

Please sign in to comment.