Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: only add dependency when unresolved #749

Merged
merged 1 commit into from
Nov 15, 2023

Conversation

luispadron
Copy link
Collaborator

Works towards the issues in #742.

This particular bug can be seen when adding an import to a built-in framework when it is not already in the builtin_modules.go file.

For example, adding import os would warn with:

gazelle: Unable to find dependency labels for os

Which is correct but it would also erroneously add a dependency in the generated BUILD.bazel file for @swiftpkg_swift_argument_parser//:Plugins_GenerateManual which then fails the build entirely.

The reason for this bug is because the logic in dependency_index.go was not ensuring that the product being added as a dep was actually a product that needed to be resolved.

In the case where all modules are resolvable (i.e. all builtin frameworks accounted for) this isn't hit as the list of modulesToResolve is exhausted before any unused products are ever considered.

@luispadron luispadron requested a review from cgrindel November 15, 2023 05:15
@luispadron luispadron force-pushed the luis/fix-extra-dep-bug-when-unresolved-module branch 2 times, most recently from 9c3f18f to fef4e51 Compare November 15, 2023 05:22
@luispadron luispadron force-pushed the luis/fix-extra-dep-bug-when-unresolved-module branch from fef4e51 to 042a92f Compare November 15, 2023 15:00
@luispadron luispadron enabled auto-merge (squash) November 15, 2023 15:09
@luispadron luispadron merged commit b2dca3f into main Nov 15, 2023
34 checks passed
@luispadron luispadron deleted the luis/fix-extra-dep-bug-when-unresolved-module branch November 15, 2023 15:34
jpsim added a commit to jpsim/rules_swift_package_manager that referenced this pull request Nov 15, 2023
* upstream/main:
  fix: only add dependency when unresolved (cgrindel#749)
  chore(deps): update dependency nicklockwood/swiftformat to from: "0.52.10" (cgrindel#745)
  chore(deps): update dependency firebase/firebase-ios-sdk to from: "10.18.0" (cgrindel#739)
renovate bot referenced this pull request in bazel-contrib/rules_bazel_integration_test Nov 27, 2023
…#253)

[![Mend Renovate logo
banner](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
|
[rules_swift_package_manager](https://togithub.com/cgrindel/rules_swift_package_manager)
| http_archive | minor | `v0.21.0` -> `v0.22.0` |

---

### Release Notes

<details>
<summary>cgrindel/rules_swift_package_manager
(rules_swift_package_manager)</summary>

###
[`v0.22.0`](https://togithub.com/cgrindel/rules_swift_package_manager/releases/tag/v0.22.0)

[Compare
Source](https://togithub.com/cgrindel/rules_swift_package_manager/compare/v0.21.0...v0.22.0)

#### What's Changed

- chore: update README.md for v0.21.0 by
[@&#8203;cgrindel-app-token-generator](https://togithub.com/cgrindel-app-token-generator)
in
[https://github.com/cgrindel/rules_swift_package_manager/pull/736](https://togithub.com/cgrindel/rules_swift_package_manager/pull/736)
- fix: only configure remote cache if the API key is available by
[@&#8203;cgrindel](https://togithub.com/cgrindel) in
[https://github.com/cgrindel/rules_swift_package_manager/pull/746](https://togithub.com/cgrindel/rules_swift_package_manager/pull/746)
- chore(deps): update dependency firebase/firebase-ios-sdk to from:
"10.18.0" by
[@&#8203;cgrindel-self-hosted-renovate](https://togithub.com/cgrindel-self-hosted-renovate)
in
[https://github.com/cgrindel/rules_swift_package_manager/pull/739](https://togithub.com/cgrindel/rules_swift_package_manager/pull/739)
- chore(deps): update dependency nicklockwood/swiftformat to from:
"0.52.10" by
[@&#8203;cgrindel-self-hosted-renovate](https://togithub.com/cgrindel-self-hosted-renovate)
in
[https://github.com/cgrindel/rules_swift_package_manager/pull/745](https://togithub.com/cgrindel/rules_swift_package_manager/pull/745)
- fix: only add dependency when unresolved by
[@&#8203;luispadron](https://togithub.com/luispadron) in
[https://github.com/cgrindel/rules_swift_package_manager/pull/749](https://togithub.com/cgrindel/rules_swift_package_manager/pull/749)
- chore(deps): update dependency
pointfreeco/swift-composable-architecture to from: "1.4.2" by
[@&#8203;cgrindel-self-hosted-renovate](https://togithub.com/cgrindel-self-hosted-renovate)
in
[https://github.com/cgrindel/rules_swift_package_manager/pull/737](https://togithub.com/cgrindel/rules_swift_package_manager/pull/737)
- feat: add support for Swift macros by
[@&#8203;jpsim](https://togithub.com/jpsim) in
[https://github.com/cgrindel/rules_swift_package_manager/pull/753](https://togithub.com/cgrindel/rules_swift_package_manager/pull/753)
- fix: correctly differentiate built-in and local modules with same name
by [@&#8203;luispadron](https://togithub.com/luispadron) in
[https://github.com/cgrindel/rules_swift_package_manager/pull/756](https://togithub.com/cgrindel/rules_swift_package_manager/pull/756)
- chore(deps): update dependency apple/swift-nio to v2.62.0 by
[@&#8203;cgrindel-self-hosted-renovate](https://togithub.com/cgrindel-self-hosted-renovate)
in
[https://github.com/cgrindel/rules_swift_package_manager/pull/754](https://togithub.com/cgrindel/rules_swift_package_manager/pull/754)
- feat: add more built in frameworks by
[@&#8203;luispadron](https://togithub.com/luispadron) in
[https://github.com/cgrindel/rules_swift_package_manager/pull/750](https://togithub.com/cgrindel/rules_swift_package_manager/pull/750)
- chore: upgrade Bazel to 7.0.0rc4 by
[@&#8203;cgrindel](https://togithub.com/cgrindel) in
[https://github.com/cgrindel/rules_swift_package_manager/pull/757](https://togithub.com/cgrindel/rules_swift_package_manager/pull/757)
- chore(deps): update dependency marmelroy/phonenumberkit to from:
"3.7.5" by
[@&#8203;cgrindel-self-hosted-renovate](https://togithub.com/cgrindel-self-hosted-renovate)
in
[https://github.com/cgrindel/rules_swift_package_manager/pull/759](https://togithub.com/cgrindel/rules_swift_package_manager/pull/759)
- chore: update CI to use Xcode 15 and Swift 5.9 by
[@&#8203;jpsim](https://togithub.com/jpsim) in
[https://github.com/cgrindel/rules_swift_package_manager/pull/760](https://togithub.com/cgrindel/rules_swift_package_manager/pull/760)
- chore: add more Xcode 14.3.1 CI exceptions by
[@&#8203;jpsim](https://togithub.com/jpsim) in
[https://github.com/cgrindel/rules_swift_package_manager/pull/765](https://togithub.com/cgrindel/rules_swift_package_manager/pull/765)
- chore: update TCA example by
[@&#8203;jpsim](https://togithub.com/jpsim) in
[https://github.com/cgrindel/rules_swift_package_manager/pull/755](https://togithub.com/cgrindel/rules_swift_package_manager/pull/755)
- chore(deps): update dependency vapor/vapor to v4.87.1 by
[@&#8203;cgrindel-self-hosted-renovate](https://togithub.com/cgrindel-self-hosted-renovate)
in
[https://github.com/cgrindel/rules_swift_package_manager/pull/767](https://togithub.com/cgrindel/rules_swift_package_manager/pull/767)
- fix: only add `generates_header` attribute if target is a library by
[@&#8203;cgrindel](https://togithub.com/cgrindel) in
[https://github.com/cgrindel/rules_swift_package_manager/pull/766](https://togithub.com/cgrindel/rules_swift_package_manager/pull/766)
- chore(deps): update dependency io_bazel_rules_go to v0.43.0 by
[@&#8203;cgrindel-self-hosted-renovate](https://togithub.com/cgrindel-self-hosted-renovate)
in
[https://github.com/cgrindel/rules_swift_package_manager/pull/763](https://togithub.com/cgrindel/rules_swift_package_manager/pull/763)
- fix(deps): update module github.com/deckarep/golang-set/v2 to v2.4.0
by
[@&#8203;cgrindel-self-hosted-renovate](https://togithub.com/cgrindel-self-hosted-renovate)
in
[https://github.com/cgrindel/rules_swift_package_manager/pull/768](https://togithub.com/cgrindel/rules_swift_package_manager/pull/768)
- chore: upgrade gazelle to 0.34.0 and rules_go to 0.43.0 by
[@&#8203;cgrindel](https://togithub.com/cgrindel) in
[https://github.com/cgrindel/rules_swift_package_manager/pull/588](https://togithub.com/cgrindel/rules_swift_package_manager/pull/588)
- fix(deps): update module github.com/bazelbuild/bazel-gazelle to
v0.34.0 by
[@&#8203;cgrindel-self-hosted-renovate](https://togithub.com/cgrindel-self-hosted-renovate)
in
[https://github.com/cgrindel/rules_swift_package_manager/pull/486](https://togithub.com/cgrindel/rules_swift_package_manager/pull/486)
- chore: avoid adding `.build` directory to client's workspace by
[@&#8203;cgrindel](https://togithub.com/cgrindel) in
[https://github.com/cgrindel/rules_swift_package_manager/pull/771](https://togithub.com/cgrindel/rules_swift_package_manager/pull/771)

**Full Changelog**:
cgrindel/rules_swift_package_manager@v0.21.0...v0.22.0

#### Bazel Module Snippet

```python
bazel_dep(name = "rules_swift_package_manager", version = "0.22.0")
```

#### Workspace Snippet

```python
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_swift_package_manager",
    sha256 = "f1ddf074651bf7b3f4977026ae49f9182e44ade975df29740e8ff6666a136f3a",
    urls = [
        "https://github.com/cgrindel/rules_swift_package_manager/releases/download/v0.22.0/rules_swift_package_manager.v0.22.0.tar.gz",
    ],
)

load("@&#8203;rules_swift_package_manager//:deps.bzl", "swift_bazel_dependencies")

swift_bazel_dependencies()

load("@&#8203;cgrindel_bazel_starlib//:deps.bzl", "bazel_starlib_dependencies")

bazel_starlib_dependencies()

### MARK: - Gazelle
### gazelle:repo bazel_gazelle

load("@&#8203;bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("@&#8203;rules_swift_package_manager//:go_deps.bzl", "swift_bazel_go_dependencies")
load("@&#8203;io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

### Declare Go dependencies before calling go_rules_dependencies.
swift_bazel_go_dependencies()

go_rules_dependencies()

go_register_toolchains(version = "1.19.1")

gazelle_dependencies()

### MARK: - Swift Toolchain

http_archive(
    name = "build_bazel_rules_swift",

### Populate with your preferred release 
### https://github.com/bazelbuild/rules_swift/releases
)

load(
    "@&#8203;build_bazel_rules_swift//swift:repositories.bzl",
    "swift_rules_dependencies",
)
load("//:swift_deps.bzl", "swift_dependencies")

### gazelle:repository_macro swift_deps.bzl%swift_dependencies
swift_dependencies()

swift_rules_dependencies()

load(
    "@&#8203;build_bazel_rules_swift//swift:extras.bzl",
    "swift_rules_extra_dependencies",
)

swift_rules_extra_dependencies()
```

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/bazel-contrib/rules_bazel_integration_test).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy41OS44IiwidXBkYXRlZEluVmVyIjoiMzcuNTkuOCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants