Skip to content
Merged
Show file tree
Hide file tree
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
70 changes: 70 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Integration test

on:
push:
branches: [main]
pull_request:

jobs:
integration:
runs-on: ubuntu-latest

permissions:
contents: read
pull-requests: read

steps:
- uses: actions/checkout@v4

- uses: ruby/setup-ruby@v1
with:
bundler-cache: true

- name: Create test Rails app
run: |
gem install rails --no-document
rails new /tmp/test-app \
--skip-git \
--skip-action-mailer \
--skip-action-mailbox \
--skip-action-text \
--skip-active-record \
--skip-active-storage \
--skip-action-cable \
--skip-bootsnap \
--skip-test \
--quiet

- name: Pin outdated packages
run: |
cat >> /tmp/test-app/config/importmap.rb << 'EOF'

pin "is-svg", to: "https://cdn.jsdelivr.net/npm/is-svg@3.0.0/index.js"
pin "md5", to: "https://cdn.jsdelivr.net/npm/md5@2.2.0/dist/md5.min.js"
pin "local-time", to: "https://cdn.jsdelivr.net/npm/local-time@3.0.2/app/assets/javascripts/local-time.es2017-esm.js"
pin "hotkeys-js", to: "https://cdn.jsdelivr.net/npm/hotkeys-js@4.0.3/dist/hotkeys.esm.js"
pin "tom-select", to: "https://cdn.jsdelivr.net/npm/tom-select@2.3.1/dist/esm/tom-select.complete.js"
pin "just-extend", to: "https://cdn.jsdelivr.net/npm/just-extend@5.1.1/index.mjs"
EOF

- name: Run in dry-run mode
uses: ./
env:
IMPORTMAP_RUN_LOG: /tmp/dry-run-output.txt
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
dry-run: "true"
working-directory: /tmp/test-app

- name: Assert all outdated packages appear in dry-run output
run: |
failed=0
for pkg in hotkeys-js is-svg just-extend local-time md5 tom-select; do
if grep -q "$pkg" /tmp/dry-run-output.txt; then
echo "✓ $pkg"
else
echo "✗ $pkg not found in output"
failed=1
fi
done
exit $failed
7 changes: 6 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ inputs:
description: "Git author email for commits."
required: false
default: "github-actions[bot]@users.noreply.github.com"
working-directory:
description: "Directory containing the Rails app to run against. Useful when the app lives in a subdirectory or for integration testing."
required: false
default: "."

runs:
using: "composite"
Expand All @@ -44,6 +48,7 @@ runs:

- name: Run importmap-update
shell: bash
working-directory: ${{ inputs.working-directory }}
env:
GH_TOKEN: ${{ inputs.github-token }}
GITHUB_TOKEN: ${{ inputs.github-token }}
Expand All @@ -53,4 +58,4 @@ runs:
IMPORTMAP_DRY_RUN: ${{ inputs.dry-run }}
IMPORTMAP_AUTHOR_NAME: ${{ inputs.author-name }}
IMPORTMAP_AUTHOR_EMAIL: ${{ inputs.author-email }}
run: ${{ github.action_path }}/exe/importmap-update
run: ${{ github.action_path }}/exe/importmap-update 2>&1 | tee "${IMPORTMAP_RUN_LOG:-/dev/null}"
6 changes: 4 additions & 2 deletions lib/executor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,10 @@ def handle_noop(action)
def handle_open(action)
spec = action.pr_spec
if @dry_run
names = spec.packages.map(&:name).join(", ")
return Outcome.new(
type: :open, status: :skipped, branch: spec.branch,
detail: "DRY RUN: would open PR for #{spec.packages.size} package(s)."
detail: "DRY RUN: would open PR for #{names}."
)
end

Expand All @@ -134,9 +135,10 @@ def handle_force_push(action)
existing = action.existing_pr

if @dry_run
names = spec.packages.map(&:name).join(", ")
return Outcome.new(
type: :force_push, status: :skipped, branch: spec.branch, pr_number: existing.number,
detail: "DRY RUN: would force-push (#{action.reason})."
detail: "DRY RUN: would force-push #{names} (#{action.reason})."
)
end

Expand Down
5 changes: 4 additions & 1 deletion test/executor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,11 @@ def test_dry_run_records_skipped_outcomes_and_invokes_nothing
assert_empty @gh.created
assert_empty @gh.updated
assert_empty @gh.closed
# All "would have" details should be informative.
assert(report.outcomes.all? { |o| o.detail.start_with?("DRY RUN") })
open_outcome = report.outcomes.find { |o| o.type == :open }
fp_outcome = report.outcomes.find { |o| o.type == :force_push }
assert_includes open_outcome.detail, "lodash"
assert_includes fp_outcome.detail, "stim"
end

# ---- failure isolation ----
Expand Down
Loading