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

feat: no longer need to check in swift_deps_index.json file and other big updates #957

Merged
merged 120 commits into from
Jun 26, 2024

Conversation

cgrindel
Copy link
Owner

@cgrindel cgrindel commented Mar 10, 2024

Lots of big changes in this PR:

  • The SPM-related rules no longer depend upon a Swift deps index JSON file.
  • Remove the from_file module extension tag class, as the ruleset no longer needs to read the Swift deps index file.
  • Remove the swift_update_packages macro as it is no longer required.
  • Remove support for byName references outside of a Swift package. This was supported in early SPM versions. It was one of the driving factors for having to pre-process the Swift dependencies and generate a Swift deps index file. Removing this support reduces the complexity of the rules_swift_package_manager implementation.
  • Remove update_repos command from the Gazelle plugin.
  • Add swift_deps_info repository rule to generate a Swift deps index JSON file as part of the build, not in the Gazelle plugin. This index file is used by the Gazelle plugin to resolve Swift module names to their respective Bazel target.
  • Introduce from_package module extension tag class telling the ruleset where the Package.swift and Package.resolved files for the workspace live. These are used to identify the Swift package transitive dependencies for the project.
  • Remove the http_archive_ext_deps example. The example existed to demonstrate and test indexing of Swift targets that were downloaded using http_archive. The Gazelle internals no longer provide some of the information needed for this to work properly with bzlmod enabled. Given that SPM has been widely adopted and there are some workarounds, we are removing support for this functionality in the Gazelle plugin when bzlmod is enabled.
  • Add output to the example test runner that demarcates different phases for the testing.

Related to #924.

@cgrindel cgrindel self-assigned this Mar 10, 2024
@cgrindel cgrindel force-pushed the gh924_no_swift_index branch 2 times, most recently from ffaea7c to 7de38da Compare April 13, 2024 17:42
@cgrindel cgrindel force-pushed the gh924_no_swift_index branch 2 times, most recently from 8ac2c18 to 67b12ea Compare May 14, 2024 00:19
@cgrindel cgrindel changed the title feat: no longer read the index file in the repository rules feat: no longer need to check in swift_deps_index.json file and other big updates Jun 16, 2024
@cgrindel cgrindel marked this pull request as ready for review June 16, 2024 20:18
@cgrindel cgrindel requested review from brentleyjones, jpsim and luispadron and removed request for jpsim June 16, 2024 20:18
Copy link
Collaborator

@brentleyjones brentleyjones left a comment

Choose a reason for hiding this comment

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

Just some minor comments. I tested it locally and it works with our project!

swiftpkg/bzlmod/swift_deps.bzl Outdated Show resolved Hide resolved
swiftpkg/bzlmod/swift_deps.bzl Outdated Show resolved Hide resolved
swiftpkg/bzlmod/swift_deps.bzl Outdated Show resolved Hide resolved
swiftpkg/bzlmod/swift_deps.bzl Outdated Show resolved Hide resolved
swiftpkg/internal/repo_rules.bzl Outdated Show resolved Hide resolved
swiftpkg/tests/pkginfo_target_deps_tests.bzl Outdated Show resolved Hide resolved
swiftpkg/tests/pkginfo_target_deps_tests.bzl Outdated Show resolved Hide resolved
@cgrindel
Copy link
Owner Author

@brentleyjones @luispadron This should be ready for another review.

swiftpkg/bzlmod/swift_deps.bzl Outdated Show resolved Hide resolved
swiftpkg/bzlmod/swift_deps.bzl Outdated Show resolved Hide resolved
swiftpkg/bzlmod/swift_deps.bzl Outdated Show resolved Hide resolved
@brentleyjones
Copy link
Collaborator

@luispadron can you give this a spin locally as well?

@luispadron
Copy link
Collaborator

Yes, I'll test and review today!

@cgrindel cgrindel enabled auto-merge (squash) June 25, 2024 23:55
@cgrindel cgrindel merged commit 4bf2ffe into main Jun 26, 2024
32 checks passed
@cgrindel cgrindel deleted the gh924_no_swift_index branch June 26, 2024 00:40
renovate bot referenced this pull request in bazel-contrib/rules_bazel_integration_test Jun 26, 2024
…#328)

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

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| rules_swift_package_manager | bazel_dep | minor | `0.33.0` -> `0.34.0`
|
|
[rules_swift_package_manager](https://togithub.com/cgrindel/rules_swift_package_manager)
| http_archive | minor | `v0.33.0` -> `v0.34.0` |

---

### Release Notes

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

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

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

#### What's Changed

- chore: update README.md for v0.33.0 by
[@&#8203;cgrindel-app-token-generator](https://togithub.com/cgrindel-app-token-generator)
in
[https://github.com/cgrindel/rules_swift_package_manager/pull/1109](https://togithub.com/cgrindel/rules_swift_package_manager/pull/1109)
- feat: no longer need to check in `swift_deps_index.json` file and
other big updates by [@&#8203;cgrindel](https://togithub.com/cgrindel)
in
[https://github.com/cgrindel/rules_swift_package_manager/pull/957](https://togithub.com/cgrindel/rules_swift_package_manager/pull/957)

**Full Changelog**:
cgrindel/rules_swift_package_manager@v0.33.0...v0.34.0

#### Bazel Module Snippet

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

#### Workspace Snippet

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

http_archive(
    name = "rules_swift_package_manager",
    sha256 = "483c0090daa1912c94dac5a9727f4d15384b667f912bb77f847a9c3fcb8541a0",
    urls = [
        "https://github.com/cgrindel/rules_swift_package_manager/releases/download/v0.34.0/rules_swift_package_manager.v0.34.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.21.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 these
updates 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:eyJjcmVhdGVkSW5WZXIiOiIzNy40MTMuMiIsInVwZGF0ZWRJblZlciI6IjM3LjQxMy4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

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.

3 participants