Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 47 additions & 5 deletions .github/workflows/foreman_plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
exclude: ${{ inputs.matrix_exclude }}

test:
name: "Foreman ${{ inputs.foreman_version }} with Ruby ${{ matrix.ruby }} and Node ${{ matrix.node }} on PostgreSQL ${{ matrix.postgresql }}"
name: "${{ matrix.task }} - Foreman ${{ inputs.foreman_version }} with Ruby ${{ matrix.ruby }} and Node ${{ matrix.node }} on PostgreSQL ${{ matrix.postgresql }}"
needs: setup_matrix
runs-on: ubuntu-latest
services:
Expand All @@ -64,7 +64,14 @@ jobs:
POSTGRES_PASSWORD: password
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.setup_matrix.outputs.matrix) }}
matrix:
ruby: ${{ fromJson(needs.setup_matrix.outputs.matrix).ruby }}
node: ${{ fromJson(needs.setup_matrix.outputs.matrix).node }}
postgresql: ${{ fromJson(needs.setup_matrix.outputs.matrix).postgresql }}
task:
- 'test:${{ inputs.plugin }}'
- 'db:seed'
- 'plugin:assets:precompile[${{ inputs.plugin }}] RAILS_ENV=production DATABASE_URL=nulldb://nohost'
steps:
- run: sudo apt-get update
- run: sudo apt-get install -y build-essential libcurl4-openssl-dev zlib1g-dev libpq-dev
Expand All @@ -91,18 +98,53 @@ jobs:
- name: Archive Gemfile.lock
uses: actions/upload-artifact@v3
with:
name: Gemfile.lock
name: Gemfile-ruby-${{ matrix.ruby }}-node-${{ matrix.node }}-pg-${{ matrix.postgresql }}.lock
path: Gemfile.lock
- name: "Set up Node ${{ matrix.node }}"
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Setup NPM Cache
if: ${{ hashFiles(format('{0}/package.json', inputs.plugin)) != '' && !contains(matrix.task, 'seed') }}
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node }}-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.node }}-
- name: "Build package-lock.json"
if: ${{ hashFiles(format('{0}/package.json', inputs.plugin)) != '' && !contains(matrix.task, 'seed') }}
run: bundle exec npm install --package-lock-only --no-audit
- name: Archive package-lock.json
if: ${{ hashFiles(format('{0}/package.json', inputs.plugin)) != '' && !contains(matrix.task, 'seed') }}
uses: actions/upload-artifact@v3
with:
name: package-lock-ruby-${{ matrix.ruby }}-node-${{ matrix.node }}-pg-${{ matrix.postgresql }}.json
path: package-lock.json
- name: "Install NPM packages"
if: ${{ hashFiles(format('{0}/package.json', inputs.plugin)) != '' && !contains(matrix.task, 'seed') }}
run: bundle exec npm ci --no-audit
- name: Prepare test env
if: ${{ !contains(matrix.task, 'nulldb') }}
run: |
bundle exec rake db:create
bundle exec rake db:migrate
- name: Run plugin tests
run: bundle exec rake test:${{ inputs.plugin }}
- name: "Compile webpack"
if: ${{ hashFiles(format('{0}/package.json', inputs.plugin)) != '' && contains(matrix.task, 'test') }}
run:
bundle exec rake webpack:compile
Comment on lines +132 to +135
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, if test:$plugin depends on webpack (because it contains integration tests), it should depend on that itself via Rake, and not make us do this hack, but 🤷‍♀️

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could argue that it can make it painful for developers. If you have webpack running then you don't need to compile, but we can't detect this. So I can accept this now. Perhaps after we merge webpack 5 we can be a bit smarter and introduce some task that only compiles if some file doesn't exist.

- name: Add nulldb DB schema
run: cp -f db/schema.rb.nulldb db/schema.rb
if: ${{ contains(matrix.task, 'nulldb') }}
- name: Run rake ${{ matrix.task }}
run: bundle exec rake ${{ matrix.task }}
- name: Upload logs
uses: actions/upload-artifact@v3
if: ${{ failure() && contains(matrix.task, 'test') }}
with:
name: logs-ruby-${{ matrix.ruby }}-node-${{ matrix.node }}-pg-${{ matrix.postgresql }}
path: log/*.log
retention-days: 5

database:
name: "Database - Foreman ${{ inputs.foreman_version }} with Ruby ${{ matrix.ruby }} and Node ${{ matrix.node }} on PostgreSQL ${{ matrix.postgresql }}"
Expand Down