diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index b409c9b..946d0d3 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -20,7 +20,7 @@ jobs: - name: Create test Rails app run: | gem install rails --no-document - rails new /tmp/test-app \ + rails new $RUNNER_TEMP/test-app \ --skip-git \ --skip-action-mailer \ --skip-action-mailbox \ @@ -31,7 +31,7 @@ jobs: --skip-bootsnap \ --skip-test \ --quiet - cd /tmp/test-app + cd $RUNNER_TEMP/test-app git init git add . git config user.email "test@example.com" @@ -40,7 +40,7 @@ jobs: - name: Pin outdated packages run: | - cd /tmp/test-app + cd $RUNNER_TEMP/test-app cat >> config/importmap.rb << 'EOF' @@ -58,17 +58,17 @@ jobs: - name: Run in dry-run mode uses: ./ env: - IMPORTMAP_RUN_LOG: /tmp/dry-run-output.txt + IMPORTMAP_RUN_LOG: ${{ runner.temp }}/dry-run-output.txt with: github-token: ${{ secrets.GITHUB_TOKEN }} dry-run: "true" - rails-root: /tmp/test-app + rails-root: ${{ runner.temp }}/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 + if grep -q "$pkg" $RUNNER_TEMP/dry-run-output.txt; then echo "✓ $pkg" else echo "✗ $pkg not found in output" diff --git a/action.yml b/action.yml index 833a65a..8546301 100644 --- a/action.yml +++ b/action.yml @@ -21,9 +21,6 @@ inputs: description: "When 'true', run end-to-end but skip all side effects (no commits, pushes, or PR operations)." required: false default: "false" - ruby-version: - description: "Ruby version to set up. Defaults to the consuming repo's .ruby-version." - required: false author-name: description: "Git author name for commits." required: false @@ -44,8 +41,8 @@ runs: shell: bash working-directory: ${{ inputs.rails-root }} run: | - bin/importmap audit 2>&1 | tee /tmp/importmap-audit.txt || true - bin/importmap outdated 2>&1 | tee /tmp/importmap-outdated.txt || true + bin/importmap audit 2>&1 | tee "${{ runner.temp }}/importmap-audit.txt" || true + bin/importmap outdated 2>&1 | tee "${{ runner.temp }}/importmap-outdated.txt" || true - name: Run importmap-update shell: bash @@ -60,9 +57,8 @@ runs: IMPORTMAP_DRY_RUN: ${{ inputs.dry-run }} IMPORTMAP_AUTHOR_NAME: ${{ inputs.author-name }} IMPORTMAP_AUTHOR_EMAIL: ${{ inputs.author-email }} + IMPORTMAP_OUTDATED_FILE: ${{ runner.temp }}/importmap-outdated.txt + IMPORTMAP_AUDIT_FILE: ${{ runner.temp }}/importmap-audit.txt run: | bundle install - bundle exec exe/importmap-update \ - --outdated-file /tmp/importmap-outdated.txt \ - --audit-file /tmp/importmap-audit.txt \ - 2>&1 | tee "${IMPORTMAP_RUN_LOG:-/dev/null}" + bundle exec exe/importmap-update 2>&1 | tee "${IMPORTMAP_RUN_LOG:-/dev/null}" diff --git a/exe/importmap-update b/exe/importmap-update index 3ee7d97..650bdae 100755 --- a/exe/importmap-update +++ b/exe/importmap-update @@ -31,16 +31,12 @@ require "parsers/audit_parser" options = { config_path: ENV.fetch("INPUT_CONFIG_FILE", ".github/importmap-updates.yml"), - outdated_file: nil, - audit_file: nil, dry_run: %w[true 1 yes].include?(ENV["IMPORTMAP_DRY_RUN"].to_s.downcase) } OptionParser.new do |opts| opts.banner = "Usage: importmap-update [options]" opts.on("-c", "--config PATH", "Path to config YAML") { |p| options[:config_path] = p } - opts.on("--outdated-file PATH", "Captured `bin/importmap outdated` output") { |p| options[:outdated_file] = p } - opts.on("--audit-file PATH", "Captured `bin/importmap audit` output") { |p| options[:audit_file] = p } opts.on("--dry-run", "Do not perform side effects; log what would happen") { options[:dry_run] = true } opts.on("-h", "--help") { puts opts @@ -55,11 +51,8 @@ rescue Importmap::Update::Config::ConfigError => e exit 2 end -missing = [:outdated_file, :audit_file].select { |k| options[k].nil? } -unless missing.empty? - warn "Missing required option(s): #{missing.map { |k| "--#{k.to_s.tr("_", "-")}" }.join(", ")}" - exit 2 -end +outdated_file = ENV.fetch("IMPORTMAP_OUTDATED_FILE") +audit_file = ENV.fetch("IMPORTMAP_AUDIT_FILE") repo = ENV["GITHUB_REPOSITORY"] if repo.nil? || repo.empty? @@ -82,8 +75,8 @@ git = Importmap::Update::GitClient.new( author_email: ENV.fetch("IMPORTMAP_AUTHOR_EMAIL", "github-actions[bot]@users.noreply.github.com") ) -outdated_output = File.read(options[:outdated_file]) -audit_output = File.read(options[:audit_file]) +outdated_output = File.read(outdated_file) +audit_output = File.read(audit_file) outdated = Importmap::Update::Parsers::OutdatedParser.parse(outdated_output) vulnerabilities = Importmap::Update::Parsers::AuditParser.parse(audit_output) plan = Importmap::Update::Planner.new(