Skip to content

Conversation

simonjbeaumont
Copy link
Collaborator

@simonjbeaumont simonjbeaumont commented Jul 30, 2025

Motivation

The command plugin is used for ahead-of-time (AOT) code generation. It can be run with --target, or without, in which case it considers all targets based on the presence of the requisite OpenAPI document and config file.

If a target is detected that doesn't have either of these files, it should be considered an error if that target was explicitly asked for using --target. If it wasn't—either because we're looking at all targets, or because it is a dependency—it should be skipped.

Modifications

  • Extend integration test to repro issue for AOT targets with dependencies
  • Skip targets that have no requisite files for generation unless they were asked for

Result

Fixes command plugin when used for AOT generation with targets with target dependencies.

Test Plan

This PR starts out with a commit that updated the integration test to repro the issue, which we should see fail in CI. Only then was a commit added to address the issue, restoring the CI to green.

@simonjbeaumont simonjbeaumont force-pushed the sb/command-plugin-transitive-target-issues branch 3 times, most recently from 5d33ea9 to e0c595c Compare July 30, 2025 16:44
@simonjbeaumont simonjbeaumont force-pushed the sb/command-plugin-transitive-target-issues branch from e0c595c to fc0bc08 Compare July 30, 2025 16:46
@simonjbeaumont simonjbeaumont added the 🔨 semver/patch No public API change. label Jul 30, 2025
@simonjbeaumont
Copy link
Collaborator Author

OK, integration test is now reproducing the issue:

Considering target 'Empty':
- Trying OpenAPI code generation.
- OpenAPI code generation failed with error.
Error: Process completed with exit code 1.

— source: https://github.com/apple/swift-openapi-generator/actions/runs/16628616709/job/47051868951?pr=801#step:4:1039

I'll add the commit with the fix.

@simonjbeaumont
Copy link
Collaborator Author

OK, now we're good:

** Running command plugin on integration test package AOT target with dependency: /tmp/run-integration-test.sh.HhqFFi4uF0/swift-openapi-generator/IntegrationTest
...
Build of product 'swift-openapi-generator' complete! (2.77s)
Considering target 'TypesAOTWithDependency':
- Trying OpenAPI code generation.
Swift OpenAPI Generator is running with the following configuration:
- OpenAPI document path: /tmp/run-integration-test.sh.HhqFFi4uF0/swift-openapi-generator/IntegrationTest/Sources/TypesAOTWithDependency/openapi.yaml
- Configuration path: /tmp/run-integration-test.sh.HhqFFi4uF0/swift-openapi-generator/IntegrationTest/Sources/TypesAOTWithDependency/openapi-generator-config.yaml
- Generator modes: types
- Access modifier: package
- Naming strategy: idiomatic
- Name overrides: <none>
- Type overrides: <none>
- Feature flags: <none>
- Output file names: Types.swift
- Output directory: /tmp/run-integration-test.sh.HhqFFi4uF0/swift-openapi-generator/IntegrationTest/Sources/TypesAOTWithDependency/GeneratedSources
- Diagnostics output path: <none - logs to stderr>
- Current directory: /swift-openapi-generator
- Plugin source: command
- Is dry run: false
- Additional imports: <none>
- Additional file comments: <none>File Types.swift already up to date.
- ✅ OpenAPI code generation for target 'TypesAOTWithDependency' successfully completed.
Considering target 'Empty':
- Trying OpenAPI code generation.
- Skipping because target isn't configured for OpenAPI code generation.
...
** Building integration test package AOT target with dependency: /tmp/run-integration-test.sh.HhqFFi4uF0/swift-openapi-generator/IntegrationTest
...
Build of target: 'TypesAOTWithDependency' complete! (3.31s)
** ✅ Successfully built integration test package.

— source: https://github.com/apple/swift-openapi-generator/actions/runs/16628720586/job/47052227723?pr=801#step:4:993

@simonjbeaumont simonjbeaumont marked this pull request as ready for review July 30, 2025 16:55
@simonjbeaumont simonjbeaumont requested a review from czechboy0 July 30, 2025 16:55
@simonjbeaumont simonjbeaumont enabled auto-merge (squash) July 30, 2025 17:04
@simonjbeaumont simonjbeaumont force-pushed the sb/command-plugin-transitive-target-issues branch from cd26ed7 to de7eb0b Compare July 30, 2025 17:09
@simonjbeaumont simonjbeaumont merged commit bb9a135 into apple:main Jul 30, 2025
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants