From 498f5baf3392f82facb8a0c518d98d7b6e3940e5 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Wed, 25 Nov 2020 13:09:05 +0100 Subject: [PATCH 01/30] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 778294d..01be899 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ import PackageDescription let package = Package( name: "YourPackageName", dependencies: [ - .package(url: "https://github.com/fireblade-engine/ecs.git", from: "0.17.3") + .package(url: "https://github.com/fireblade-engine/ecs.git", from: "0.17.4") ], targets: [ .target( From c997e078178113ff20e733942b81dea341c84f3d Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Wed, 25 Nov 2020 13:12:51 +0100 Subject: [PATCH 02/30] Update CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 400a51e..c18d11a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: runs-on: macOS-latest strategy: matrix: - xcode: ["11.7", "12"] + xcode: ["11.7", "12.2"] steps: - name: Checkout uses: actions/checkout@master From ddd676514b3462a26fda58eb25911ceb4ea2878f Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Thu, 3 Dec 2020 11:29:41 +0100 Subject: [PATCH 03/30] Add FUNDING.yml --- .github/FUNDING.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..e69de29 From 541e21d9c9493de8f62b9279ecfb9529c9087684 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Thu, 3 Dec 2020 11:34:27 +0100 Subject: [PATCH 04/30] Update FUNDING.yml --- .github/FUNDING.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index e69de29..f3fc2f4 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: [ctreffs] +custom: ['https://www.paypal.com/donate?hosted_button_id=GCG3K54SKRALQ'] From 68daff2b6df36b4a0fe082f19a099c30e58236ad Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 3 May 2021 08:04:46 +0200 Subject: [PATCH 05/30] Add community files --- .github/ISSUE_TEMPLATE/BUG_REPORT.md | 61 ++++++++ .github/ISSUE_TEMPLATE/FEATURE_REQUEST.md | 31 ++++ .github/ISSUE_TEMPLATE/config.yml | 5 + .../PULL_REQUEST_TEMPLATE.md | 52 +++++++ CODEOWNERS | 12 ++ CODE_OF_CONDUCT.md | 136 ++++++++++++++++++ CONTRIBUTING.md | 18 +-- 7 files changed, 307 insertions(+), 8 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/BUG_REPORT.md create mode 100644 .github/ISSUE_TEMPLATE/FEATURE_REQUEST.md create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.md create mode 100644 CODEOWNERS create mode 100644 CODE_OF_CONDUCT.md diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.md b/.github/ISSUE_TEMPLATE/BUG_REPORT.md new file mode 100644 index 0000000..3d6cc43 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.md @@ -0,0 +1,61 @@ +--- +name: 🐛 Bug Report +about: Something isn't working as expected, create a report to help us improve +labels: bug +--- + + + +### Bug Description + +*A clear and concise description of what the bug is. +Replace this paragraph with a short description of the incorrect behavior. +(If this is a regression, please note the last version of the package that exhibited the correct behavior in addition to your current version.)* + +### Information + +- **Package version:** What tag or branch of this package are you using? e.g. tag `1.2.3` or branch `main` +- **Platform version:** Please tell us the version number of your operating system. e.g. `macOS 11.2.3` or `Ubuntu 20.04` +- **Swift version:** Paste the output of `swift --version` here. + +### Checklist + +- [ ] If possible, I've reproduced the issue using the `main`/`master` branch of this package. +- [ ] I've searched for existing issues under the issues tab. +- [ ] The bug is reproducible + +### Steps to Reproduce + +*Steps to reproduce the behavior:* + +1. Go to '...' +2. '....' + +*Replace this paragraph with an explanation of how to reproduce the incorrect behavior. +Include a simple code example, if possible.* + +### Expected behavior + +*A clear and concise description of what you expected to happen. +Describe what you expect to happen.* + +### Actual behavior + +*Describe or copy/paste the behavior you observe.* + +### Screenshots + +If applicable, add screenshots to help explain your problem. + +### Additional context + +*Add any other context about the problem here.* diff --git a/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md new file mode 100644 index 0000000..74cd661 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md @@ -0,0 +1,31 @@ +--- +name: 💡 Feature Request +about: A suggestion for a new feature or idea for this project +labels: enhancement +--- + + + +### Feature request + +*Replace this paragraph with a description of your proposed feature. +A clear and concise description of what the idea or problem is you want to solve. +Please be sure to describe some concrete use cases for the new feature -- be as specific as possible. +Provide links to existing issues or external references/discussions, if appropriate.* + +### Describe the solution you'd like + +*A clear and concise description of what you want to happen.* + +### Describe alternatives you've considered + +*A clear and concise description of any alternative solutions or features you've considered.* + +### Additional context + +*Add any other context or screenshots about the feature request here.* diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..67bcb21 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: Discord + url: https://discord.gg/JMM7W6pCCc + about: Questions or comments about using Fireblade? Ask here! diff --git a/.github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..4025401 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,52 @@ + + +### Description + +*Replace this paragraph with a description of your changes and rationale. +Provide links to an existing issue or external references/discussions, if appropriate.* + +### Detailed Design + +*Include any additional information about the design here. At minimum, describe a synopsis of any public API additions.* + +```swift +/// The new feature implemented by this pull request. +public struct Example: Collection { +} +``` + +### Documentation + +*How has the new feature been documented? +Have the relevant portions of the guides in the Documentation folder been updated in addition to symbol-level documentation?* + +### Testing + +*How is the new feature tested? +Please ensure CI is not broken* + +### Performance + +*How did you verify the new feature performs as expected?* + +### Source Impact + +*What is the impact of this change on existing users of this package? Does it deprecate or remove any existing API?* + +### Checklist + +- [ ] I've read the [Contribution Guidelines]( https://github.com/fireblade-engine/ecs/CONTRIBUTING.md) +- [ ] I've followed the coding style of the rest of the project. +- [ ] I've added tests covering all new code paths my change adds to the project (to the extent possible). +- [ ] I've added benchmarks covering new functionality (if appropriate). +- [ ] I've verified that my change does not break any existing tests or introduce unexpected benchmark regressions. +- [ ] I've updated the documentation (if appropriate). diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..5ac9aba --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,12 @@ +# This file is a list of the people responsible for ensuring that contributions +# to this projected are reviewed, either by themselves or by someone else. +# They are also the gatekeepers for their part of this project, with the final +# word on what goes in or not. +# The code owners file uses a .gitignore-like syntax to specify which parts of +# the codebase is associated with an owner. See +# +# for details. +# The following lines are used by GitHub to automatically recommend reviewers. +# Each line is a file pattern followed by one or more owners. + +* @ctreffs diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..52ce96e --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,136 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement +e.g. via [content abuse report][ref-report-abuse]. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][ref-homepage-cc], +version 2.0, available at +. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +For answers to common questions about this code of conduct, see the FAQ at +. +Translations are available at +. + + + +[ref-homepage-cc]: https://www.contributor-covenant.org +[ref-report-abuse]: https://docs.github.com/communities/maintaining-your-safety-on-github/reporting-abuse-or-spam#reporting-an-issue-or-pull-request +[ref-gh-coc]: https://docs.github.com/en/communities/setting-up-your-project-for-healthy-contributions/adding-a-code-of-conduct-to-your-project +[ref-gh-abuse]: https://docs.github.com/en/communities/moderating-comments-and-conversations/managing-how-contributors-report-abuse-in-your-organizations-repository +[ref-coc-guide]: https://opensource.guide/code-of-conduct/ + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b8acc74..fb28e89 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,18 +8,18 @@ The following is a set of **guidelines for contributing** to this project. Use your best judgment and feel free to propose changes to this document in a pull request. -**Working on your first Pull Request?** You can learn how from this *free* series [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github) +**Working on your first Pull Request?** You can learn how from this *free* series [How to Contribute to an Open Source Project on GitHub](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github) ### 💡 Your contribution - the sky is the limit 🌈 This is an open source project and we love to receive contributions from our community — [**you**][ref-contributors]! -There are many ways to contribute, from writing __tutorials__ or __blog posts__, improving the [__documentation__][ref-documentation], submitting __bug reports__ and __feature requests__ or -__writing code__ which can be incorporated into the repository itself. +There are many ways to contribute, from writing __tutorials__ or __blog posts__, improving the [__documentation__][ref-documentation], submitting [__bug reports__][ref-issues-new] and [__enhancement__][ref-pull-request-new] or +[__writing code__][ref-pull-request-new] which can be incorporated into the repository itself. -When contributing to this project, please feel free to discuss the change you wish to make via issue with the repository owners before making a change. +When contributing to this project, please feel free to discuss the changes and ideas you wish to contribute with the repository owners before making a change by opening a [new issue][ref-issues-new] and add the **feature request** tag to that issue. - +Note that we have a [code of conduct][ref-code-of-conduct], please follow it in all your interactions with the project. ### 🐞 You want to report a bug or file an issue? @@ -55,11 +55,12 @@ If you want to start somewhere, this would be a good place to start. That said, these aren't necessarily the easiest tickets. For any new contributions please consider these guidelines: + 1. Open a [new pull request (PR)][ref-pull-request-new] with a **clear and descriptive title** 2. Write a **detailed comment** with as much relevant information as possible including: - What your feature is intended to do? - How it can be used? - - What alternatives where considered? + - What alternatives where considered, if any? - Has this feature impact on performance or stability of the project? #### Your contribution responsibilities @@ -68,7 +69,7 @@ Don't be intimidated by these responsibilities, they are easy to meet if you tak - [x] Create issues for any major changes and enhancements that you wish to make. Discuss things transparently and get community feedback. - [x] Ensure (cross-)platform compatibility for every change that's accepted. An addition should not reduce the number of platforms that the project supports. -- [x] Ensure **coding conventions** are met. Lint your code with the project's default tools. +- [x] Ensure **coding conventions** are met. Lint your code with the project's default tools. Project wide commands are available through the [Makefile][ref-makefile] in the repository root. - [x] Add tests for your feature that prove it's working as expected. Code coverage should not drop below its previous value. - [x] Ensure none of the existing tests are failing after adding your changes. - [x] Document your public API code and ensure to add code comments where necessary. @@ -80,7 +81,7 @@ Please consult the [README][ref-readme] for installation instructions. -[ref-code-of-conduct]: t.b.d. +[ref-code-of-conduct]: https://github.com/fireblade-engine/ecs/CODE_OF_CONDUCT.md [ref-contributors]: https://github.com/fireblade-engine/ecs/graphs/contributors [ref-documentation]: https://github.com/fireblade-engine/ecs/wiki [ref-gh-actions]: https://github.com/fireblade-engine/ecs/actions @@ -91,3 +92,4 @@ Please consult the [README][ref-readme] for installation instructions. [ref-pull-request-how-to]: https://docs.github.com/en/github/writing-on-github/autolinked-references-and-urls [ref-pull-request-new]: https://github.com/fireblade-engine/ecs/compare [ref-readme]: https://github.com/fireblade-engine/ecs/blob/master/README.md +[ref-makefile]: https://github.com/fireblade-engine/ecs/blob/master/Makefile From f2fbeedc8905560724b5982ee9620a0cd70cee22 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 3 May 2021 08:17:01 +0200 Subject: [PATCH 06/30] Update and rename PULL_REQUEST_TEMPLATE.md to pull_request_template.md Fix CONTRIBUTING.md link --- .../{PULL_REQUEST_TEMPLATE.md => pull_request_template.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/PULL_REQUEST_TEMPLATE/{PULL_REQUEST_TEMPLATE.md => pull_request_template.md} (97%) diff --git a/.github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md similarity index 97% rename from .github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.md rename to .github/PULL_REQUEST_TEMPLATE/pull_request_template.md index 4025401..fbb8379 100644 --- a/.github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md @@ -44,7 +44,7 @@ Please ensure CI is not broken* ### Checklist -- [ ] I've read the [Contribution Guidelines]( https://github.com/fireblade-engine/ecs/CONTRIBUTING.md) +- [ ] I've read the [Contribution Guidelines]( https://github.com/fireblade-engine/ecs/master/CONTRIBUTING.md) - [ ] I've followed the coding style of the rest of the project. - [ ] I've added tests covering all new code paths my change adds to the project (to the extent possible). - [ ] I've added benchmarks covering new functionality (if appropriate). From 1bec85a3dcaafbbe4fb8cf4e544f73f126e2ff43 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 3 May 2021 08:19:44 +0200 Subject: [PATCH 07/30] Update CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fb28e89..f3be4b9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -81,7 +81,7 @@ Please consult the [README][ref-readme] for installation instructions. -[ref-code-of-conduct]: https://github.com/fireblade-engine/ecs/CODE_OF_CONDUCT.md +[ref-code-of-conduct]: https://github.com/fireblade-engine/ecs/blob/master/CODE_OF_CONDUCT.md [ref-contributors]: https://github.com/fireblade-engine/ecs/graphs/contributors [ref-documentation]: https://github.com/fireblade-engine/ecs/wiki [ref-gh-actions]: https://github.com/fireblade-engine/ecs/actions From 4a879677228d6df9f1651a4a195b707210a36526 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 3 May 2021 08:20:19 +0200 Subject: [PATCH 08/30] Update pull_request_template.md --- .github/PULL_REQUEST_TEMPLATE/pull_request_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md index fbb8379..8838cc3 100644 --- a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +++ b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md @@ -44,7 +44,7 @@ Please ensure CI is not broken* ### Checklist -- [ ] I've read the [Contribution Guidelines]( https://github.com/fireblade-engine/ecs/master/CONTRIBUTING.md) +- [ ] I've read the [Contribution Guidelines](https://github.com/fireblade-engine/ecs/blob/master/CONTRIBUTING.md) - [ ] I've followed the coding style of the rest of the project. - [ ] I've added tests covering all new code paths my change adds to the project (to the extent possible). - [ ] I've added benchmarks covering new functionality (if appropriate). From 0161470415d5819ca2762d62444d09f6dbac382f Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 3 May 2021 10:24:12 +0200 Subject: [PATCH 09/30] Rename .github/PULL_REQUEST_TEMPLATE/pull_request_template.md to .github/pull_request_template.md --- .github/{PULL_REQUEST_TEMPLATE => }/pull_request_template.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{PULL_REQUEST_TEMPLATE => }/pull_request_template.md (100%) diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/pull_request_template.md similarity index 100% rename from .github/PULL_REQUEST_TEMPLATE/pull_request_template.md rename to .github/pull_request_template.md From 2aaef3d111b89a704790faed7f090455d9682857 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Thu, 10 Jun 2021 02:03:03 +0200 Subject: [PATCH 10/30] Update CI (#42) * Split CI actions into dedicated files * Fix pipelines * Rename pipeline jobs * Update README --- .github/workflows/ci-linux.yml | 39 +++++++++++++++ .github/workflows/ci-macos.yml | 35 ++++++++++++++ .github/workflows/ci-wasm.yml | 17 +++++++ .github/workflows/ci-windows.yml | 38 +++++++++++++++ .github/workflows/ci.yml | 81 -------------------------------- README.md | 8 ++-- 6 files changed, 134 insertions(+), 84 deletions(-) create mode 100644 .github/workflows/ci-linux.yml create mode 100644 .github/workflows/ci-macos.yml create mode 100644 .github/workflows/ci-wasm.yml create mode 100644 .github/workflows/ci-windows.yml delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml new file mode 100644 index 0000000..d254443 --- /dev/null +++ b/.github/workflows/ci-linux.yml @@ -0,0 +1,39 @@ +name: Linux + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + linux-test-build-release: + runs-on: ubuntu-latest + strategy: + matrix: + swift: ["5.1", "latest"] + container: + image: swift:${{ matrix.swift }} + steps: + - name: Checkout + uses: actions/checkout@master + - name: "Update APT" + shell: bash + run: "apt update" + - name: "Install curl" + shell: bash + run: "apt-get install -y curl" + - name: Swift version + run: swift --version + - name: Test + run: swift test -v --skip-update --parallel --enable-test-discovery --enable-code-coverage + - name: Generate coverage report + run: llvm-cov export -format="lcov" .build/debug/*PackageTests.xctest -instr-profile .build/debug/codecov/default.profdata > coverage.lcov + - name: Upload code coverage report + uses: codecov/codecov-action@master + with: + token: ${{secrets.CODECOV_TOKEN}} + file: coverage.lcov + fail_ci_if_error: true + - name: Build Release + run: swift build -c release diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml new file mode 100644 index 0000000..8766baa --- /dev/null +++ b/.github/workflows/ci-macos.yml @@ -0,0 +1,35 @@ +name: macOS + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + macos-test-build-release-xcode: + runs-on: macOS-latest + strategy: + matrix: + xcode: ["11.7", "12.4"] + steps: + - name: Checkout + uses: actions/checkout@master + - name: Select Xcode ${{ matrix.xcode }} + run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app + - name: Test + run: swift test -v --skip-update --parallel --enable-test-discovery --enable-code-coverage + env: + DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer + - name: Generate coverage report + run: xcrun llvm-cov export -format="lcov" .build/debug/*PackageTests.xctest/Contents/MacOS/*PackageTests -instr-profile .build/debug/codecov/default.profdata > coverage.lcov + - name: Upload code coverage report + uses: codecov/codecov-action@master + with: + token: ${{secrets.CODECOV_TOKEN}} + file: coverage.lcov + fail_ci_if_error: true + - name: Build Release + run: swift build -c release + env: + DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer \ No newline at end of file diff --git a/.github/workflows/ci-wasm.yml b/.github/workflows/ci-wasm.yml new file mode 100644 index 0000000..babbaba --- /dev/null +++ b/.github/workflows/ci-wasm.yml @@ -0,0 +1,17 @@ +name: WASM + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + wasm-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Build + uses: swiftwasm/swiftwasm-action@main + with: + shell-action: swift build --triple wasm32-unknown-wasi diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml new file mode 100644 index 0000000..3b75fcd --- /dev/null +++ b/.github/workflows/ci-windows.yml @@ -0,0 +1,38 @@ +name: Windows + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + windows-test-build-release: + runs-on: windows-latest + env: + SNAPSHOT: "https://swift.org/builds/swift-5.4.1-release/windows10/swift-5.4.1-RELEASE/swift-5.4.1-RELEASE-windows10.exe" + steps: + - uses: actions/checkout@master + - uses: seanmiddleditch/gha-setup-vsdevenv@master + + - name: Install Swift + run: | + Install-Binary -Url "${env:SNAPSHOT}" -Name "installer.exe" -ArgumentList ("-q") + - name: Set Environment Variables + run: | + echo "SDKROOT=C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + echo "DEVELOPER_DIR=C:\Library\Developer" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + - name: Adjust Paths + run: | + echo "C:\Library\Swift-development\bin;C:\Library\icu-67\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + echo "C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + - name: Install Supporting Files + run: | + Copy-Item "$env:SDKROOT\usr\share\ucrt.modulemap" -destination "$env:UniversalCRTSdkDir\Include\$env:UCRTVersion\ucrt\module.modulemap" + Copy-Item "$env:SDKROOT\usr\share\visualc.modulemap" -destination "$env:VCToolsInstallDir\include\module.modulemap" + Copy-Item "$env:SDKROOT\usr\share\visualc.apinotes" -destination "$env:VCToolsInstallDir\include\visualc.apinotes" + Copy-Item "$env:SDKROOT\usr\share\winsdk.modulemap" -destination "$env:UniversalCRTSdkDir\Include\$env:UCRTVersion\um\module.modulemap" + - name: Test + run: swift test -v --skip-update --parallel --enable-test-discovery + - name: Build Release + run: swift build -c release \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index c18d11a..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,81 +0,0 @@ -name: CI - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - macOS: - runs-on: macOS-latest - strategy: - matrix: - xcode: ["11.7", "12.2"] - steps: - - name: Checkout - uses: actions/checkout@master - - name: Select Xcode ${{ matrix.xcode }} - run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app - - name: Swift version - run: swift --version - - name: Test - run: swift test -v --skip-update --parallel --enable-test-discovery --enable-code-coverage - env: - DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer - - name: Generate coverage report - run: xcrun llvm-cov export -format="lcov" .build/debug/*PackageTests.xctest/Contents/MacOS/*PackageTests -instr-profile .build/debug/codecov/default.profdata > coverage.lcov - - name: Upload code coverage report - uses: codecov/codecov-action@master - with: - token: ${{secrets.CODECOV_TOKEN}} - file: coverage.lcov - fail_ci_if_error: true - - name: Build Release - run: swift build -c release - env: - DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer - - linux: - runs-on: ubuntu-latest - strategy: - matrix: - swift: ["5.1", "latest"] - container: - image: swift:${{ matrix.swift }} - steps: - - name: Checkout - uses: actions/checkout@master - - name: "Update APT" - shell: bash - run: "apt update" - - name: "Install curl" - shell: bash - run: "apt-get install -y curl" - - name: Swift version - run: swift --version - - name: Test - run: swift test -v --skip-update --parallel --enable-test-discovery --enable-code-coverage - - name: Generate coverage report - run: llvm-cov export -format="lcov" .build/debug/*PackageTests.xctest -instr-profile .build/debug/codecov/default.profdata > coverage.lcov - - name: Upload code coverage report - uses: codecov/codecov-action@master - with: - token: ${{secrets.CODECOV_TOKEN}} - file: coverage.lcov - fail_ci_if_error: true - - name: Build Release - run: swift build -c release - - - webAssembly: - runs-on: ubuntu-20.04 - steps: - - name: Checkout - uses: actions/checkout@master - - name: Swift version - run: swift --version - - name: Build - uses: swiftwasm/swiftwasm-action@main - with: - shell-action: swift build --triple wasm32-unknown-wasi diff --git a/README.md b/README.md index 01be899..081d175 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,13 @@ # Fireblade ECS (Entity-Component System) [![license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE) -[![github CI](https://github.com/fireblade-engine/ecs/workflows/CI/badge.svg)](https://github.com/fireblade-engine/ecs/actions?query=workflow%3ACI) -[![codecov](https://codecov.io/gh/fireblade-engine/ecs/branch/master/graph/badge.svg)](https://codecov.io/gh/fireblade-engine/ecs) +[![macOS](https://github.com/fireblade-engine/ecs/actions/workflows/ci-macos.yml/badge.svg)](https://github.com/fireblade-engine/ecs/actions/workflows/ci-macos.yml) +[![Linux](https://github.com/fireblade-engine/ecs/actions/workflows/ci-linux.yml/badge.svg)](https://github.com/fireblade-engine/ecs/actions/workflows/ci-linux.yml) +[![Windows](https://github.com/fireblade-engine/ecs/actions/workflows/ci-windows.yml/badge.svg)](https://github.com/fireblade-engine/ecs/actions/workflows/ci-windows.yml) +[![WASM](https://github.com/fireblade-engine/ecs/actions/workflows/ci-wasm.yml/badge.svg)](https://github.com/fireblade-engine/ecs/actions/workflows/ci-wasm.yml) [![documentation](https://github.com/fireblade-engine/ecs/workflows/Documentation/badge.svg)](https://github.com/fireblade-engine/ecs/wiki) +[![codecov](https://codecov.io/gh/fireblade-engine/ecs/branch/master/graph/badge.svg)](https://codecov.io/gh/fireblade-engine/ecs) [![spi-swift-versions](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Ffireblade-engine%2Fecs%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/fireblade-engine/ecs) [![spi-swift-platforms](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Ffireblade-engine%2Fecs%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/fireblade-engine/ecs) -[![platform-webassembly](https://img.shields.io/badge/Platform-WebAssembly-blue.svg)](https://github.com/swiftwasm/swift#swiftwasm) This is a **dependency free**, **lightweight**, **fast** and **easy to use** [Entity-Component System](https://en.wikipedia.org/wiki/Entity_component_system) implementation in Swift. It is developed and maintained as part of the [Fireblade Game Engine project](https://github.com/fireblade-engine). From af32c8d0fda69d2e1a43ccbba3adaca828b03fe7 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Fri, 11 Jun 2021 12:56:05 +0200 Subject: [PATCH 11/30] Upload artifacts (#43) * Upload artifacts * Update ci-macos.yml * Update ci-macos.yml * Update CI --- .github/workflows/ci-macos.yml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index 8766baa..be6dc0e 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -21,6 +21,14 @@ jobs: run: swift test -v --skip-update --parallel --enable-test-discovery --enable-code-coverage env: DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer + - name: Upload test artifacts + if: failure() + uses: actions/upload-artifact@v2.2.3 + with: + name: test-artifacts-${{ matrix.xcode }}-${{ github.run_id }} + path: | + .build/**/*.json + .build/**/*.xctest - name: Generate coverage report run: xcrun llvm-cov export -format="lcov" .build/debug/*PackageTests.xctest/Contents/MacOS/*PackageTests -instr-profile .build/debug/codecov/default.profdata > coverage.lcov - name: Upload code coverage report @@ -32,4 +40,16 @@ jobs: - name: Build Release run: swift build -c release env: - DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer \ No newline at end of file + DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer + - name: Upload build artifacts + uses: actions/upload-artifact@v2.2.3 + with: + name: build-artifacts-${{ matrix.xcode }}-${{ github.run_id }} + path: | + *.lcov + .build/*.yaml + .build/**/*.a + .build/**/*.so + .build/**/*.dylib + .build/**/*.dSYM + .build/**/*.json From a993671120004f97c1a99d98b384755d9b6b20d2 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Fri, 11 Jun 2021 15:21:53 +0200 Subject: [PATCH 12/30] Upload artifacts only on failure --- .github/workflows/ci-macos.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index be6dc0e..f4fa006 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -42,6 +42,7 @@ jobs: env: DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer - name: Upload build artifacts + if: failure() uses: actions/upload-artifact@v2.2.3 with: name: build-artifacts-${{ matrix.xcode }}-${{ github.run_id }} From fd57037a6df5aa7fb8070d6af105650fb84c340c Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Fri, 16 Jul 2021 07:55:39 +0200 Subject: [PATCH 13/30] Rename @_functionBuilder to @resultBuilder for Swift 5.4+ (#44) * Rename @_functionBuilder to @resultBuilder for Swift 5.4+ * Pin codecov version --- .github/workflows/ci-linux.yml | 2 +- .github/workflows/ci-macos.yml | 2 +- Sources/FirebladeECS/FamilyMemberBuilder.swift | 8 ++++++-- Sources/FirebladeECS/Nexus+ComponentsBuilder.swift | 8 ++++++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index d254443..0a608bf 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -30,7 +30,7 @@ jobs: - name: Generate coverage report run: llvm-cov export -format="lcov" .build/debug/*PackageTests.xctest -instr-profile .build/debug/codecov/default.profdata > coverage.lcov - name: Upload code coverage report - uses: codecov/codecov-action@master + uses: codecov/codecov-action@v1.5.2 with: token: ${{secrets.CODECOV_TOKEN}} file: coverage.lcov diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index f4fa006..d0363e6 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -32,7 +32,7 @@ jobs: - name: Generate coverage report run: xcrun llvm-cov export -format="lcov" .build/debug/*PackageTests.xctest/Contents/MacOS/*PackageTests -instr-profile .build/debug/codecov/default.profdata > coverage.lcov - name: Upload code coverage report - uses: codecov/codecov-action@master + uses: codecov/codecov-action@v1.5.2 with: token: ${{secrets.CODECOV_TOKEN}} file: coverage.lcov diff --git a/Sources/FirebladeECS/FamilyMemberBuilder.swift b/Sources/FirebladeECS/FamilyMemberBuilder.swift index c1c79bf..044cc54 100644 --- a/Sources/FirebladeECS/FamilyMemberBuilder.swift +++ b/Sources/FirebladeECS/FamilyMemberBuilder.swift @@ -5,6 +5,10 @@ // Created by Christian Treffs on 07.08.20. // +#if swift(<5.4) @_functionBuilder -public enum FamilyMemberBuilderPreview where R: FamilyRequirementsManaging { } -public typealias FamilyMemberBuilder = FamilyMemberBuilderPreview where R: FamilyRequirementsManaging +public enum FamilyMemberBuilder where R: FamilyRequirementsManaging { } +#else +@resultBuilder +public enum FamilyMemberBuilder where R: FamilyRequirementsManaging { } +#endif diff --git a/Sources/FirebladeECS/Nexus+ComponentsBuilder.swift b/Sources/FirebladeECS/Nexus+ComponentsBuilder.swift index e48bab5..ce4b293 100644 --- a/Sources/FirebladeECS/Nexus+ComponentsBuilder.swift +++ b/Sources/FirebladeECS/Nexus+ComponentsBuilder.swift @@ -5,9 +5,13 @@ // Created by Christian Treffs on 30.07.20. // +#if swift(<5.4) @_functionBuilder -public enum ComponentsBuilderPreview { } -public typealias ComponentsBuilder = ComponentsBuilderPreview +public enum ComponentsBuilder { } +#else +@resultBuilder +public enum ComponentsBuilder { } +#endif extension ComponentsBuilder { public static func buildBlock(_ components: Component...) -> [Component] { From 6f1ddd2bc47f91dcc11e4dba7394c27efdefcd18 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Tue, 21 Sep 2021 16:09:06 +0200 Subject: [PATCH 14/30] Update macOS CI (#45) * Move to macOS 11 * Use Xcode 13.0 * Remove .swift-version --- .github/workflows/ci-macos.yml | 4 ++-- .swift-version | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 .swift-version diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index d0363e6..2db20fc 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -8,10 +8,10 @@ on: jobs: macos-test-build-release-xcode: - runs-on: macOS-latest + runs-on: macOS-11 strategy: matrix: - xcode: ["11.7", "12.4"] + xcode: ["11.7", "12.5.1", "13.0"] steps: - name: Checkout uses: actions/checkout@master diff --git a/.swift-version b/.swift-version deleted file mode 100644 index cdb98d2..0000000 --- a/.swift-version +++ /dev/null @@ -1 +0,0 @@ -5.1.3 From 7c60425de0606236ad72112402ddfa27a842a888 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Thu, 20 Apr 2023 09:19:00 +0200 Subject: [PATCH 15/30] Update CI (#49) * Update ci-windows.yml * Update ci-macos.yml * Update ci-wasm.yml * Update ci-macos.yml * Update ci-linux.yml * Update documentation.yml --- .github/workflows/ci-linux.yml | 4 +-- .github/workflows/ci-macos.yml | 8 +++--- .github/workflows/ci-wasm.yml | 4 +-- .github/workflows/ci-windows.yml | 39 ++++++++++------------------- .github/workflows/documentation.yml | 4 +-- 5 files changed, 23 insertions(+), 36 deletions(-) diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 0a608bf..206a21f 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -11,12 +11,12 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - swift: ["5.1", "latest"] + swift: ["latest"] container: image: swift:${{ matrix.swift }} steps: - name: Checkout - uses: actions/checkout@master + uses: actions/checkout@v3 - name: "Update APT" shell: bash run: "apt update" diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index 2db20fc..0057b8b 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -8,13 +8,13 @@ on: jobs: macos-test-build-release-xcode: - runs-on: macOS-11 + runs-on: macOS-latest strategy: matrix: - xcode: ["11.7", "12.5.1", "13.0"] + xcode: ["13.4.1", "14.2"] steps: - name: Checkout - uses: actions/checkout@master + uses: actions/checkout@v3 - name: Select Xcode ${{ matrix.xcode }} run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app - name: Test @@ -32,7 +32,7 @@ jobs: - name: Generate coverage report run: xcrun llvm-cov export -format="lcov" .build/debug/*PackageTests.xctest/Contents/MacOS/*PackageTests -instr-profile .build/debug/codecov/default.profdata > coverage.lcov - name: Upload code coverage report - uses: codecov/codecov-action@v1.5.2 + uses: codecov/codecov-action@v3.1.2 with: token: ${{secrets.CODECOV_TOKEN}} file: coverage.lcov diff --git a/.github/workflows/ci-wasm.yml b/.github/workflows/ci-wasm.yml index babbaba..9678910 100644 --- a/.github/workflows/ci-wasm.yml +++ b/.github/workflows/ci-wasm.yml @@ -10,8 +10,8 @@ jobs: wasm-build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@master + - uses: actions/checkout@v3 - name: Build - uses: swiftwasm/swiftwasm-action@main + uses: swiftwasm/swiftwasm-action@v5.7 with: shell-action: swift build --triple wasm32-unknown-wasi diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index 3b75fcd..0432d28 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -9,30 +9,17 @@ on: jobs: windows-test-build-release: runs-on: windows-latest - env: - SNAPSHOT: "https://swift.org/builds/swift-5.4.1-release/windows10/swift-5.4.1-RELEASE/swift-5.4.1-RELEASE-windows10.exe" steps: - - uses: actions/checkout@master - - uses: seanmiddleditch/gha-setup-vsdevenv@master - - - name: Install Swift - run: | - Install-Binary -Url "${env:SNAPSHOT}" -Name "installer.exe" -ArgumentList ("-q") - - name: Set Environment Variables - run: | - echo "SDKROOT=C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - echo "DEVELOPER_DIR=C:\Library\Developer" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - name: Adjust Paths - run: | - echo "C:\Library\Swift-development\bin;C:\Library\icu-67\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - echo "C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - - name: Install Supporting Files - run: | - Copy-Item "$env:SDKROOT\usr\share\ucrt.modulemap" -destination "$env:UniversalCRTSdkDir\Include\$env:UCRTVersion\ucrt\module.modulemap" - Copy-Item "$env:SDKROOT\usr\share\visualc.modulemap" -destination "$env:VCToolsInstallDir\include\module.modulemap" - Copy-Item "$env:SDKROOT\usr\share\visualc.apinotes" -destination "$env:VCToolsInstallDir\include\visualc.apinotes" - Copy-Item "$env:SDKROOT\usr\share\winsdk.modulemap" -destination "$env:UniversalCRTSdkDir\Include\$env:UCRTVersion\um\module.modulemap" - - name: Test - run: swift test -v --skip-update --parallel --enable-test-discovery - - name: Build Release - run: swift build -c release \ No newline at end of file + - uses: compnerd/gha-setup-swift@main + with: + branch: swift-5.7-release + tag: 5.7-RELEASE + + - name: Checkout + uses: actions/checkout@v3 + + - name: Test + run: swift test -v --skip-update --parallel --enable-test-discovery + + - name: Build Release + run: swift build -c release diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index ed63bdb..d6768ce 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -18,8 +18,8 @@ jobs: steps: - uses: actions/checkout@master - - name: Generate documentation - uses: SwiftDocOrg/swift-doc@master + - name: Generate Swift Doc Documentation + uses: SwiftDocOrg/swift-doc@1.0.0-rc.1 with: inputs: "Sources/FirebladeECS" output: "Documentation" From e7151356b84d3eb119dca6e61ab0db89d6bd1292 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 20 Apr 2023 09:20:02 +0200 Subject: [PATCH 16/30] Add renovate.json (#48) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- renovate.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 renovate.json diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..39a2b6e --- /dev/null +++ b/renovate.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:base" + ] +} From 7b077419edc9a2e0996cc5440917ab40537fd255 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 20 Apr 2023 09:21:22 +0200 Subject: [PATCH 17/30] Update swift Docker tag to v5.8.0 (#51) * Update swift Docker tag to v5.8.0 * Delete .gitlab-ci.yml --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Christian Treffs --- .gitlab-ci.yml | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 3db5809..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,25 +0,0 @@ -image: swift:5.1.3 - -stages: - - test - - build_release - -build_project: - stage: build_release - script: - - swift package reset - - swift build -c release - tags: - - docker - only: - - master - -test_project: - stage: test - variables: - GIT_DEPTH: "50" - script: - - swift package reset - - swift test - tags: - - docker \ No newline at end of file From 4fd8aac469eb9c2b411233d0ef6b4191145a0827 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 20 Apr 2023 07:31:46 +0000 Subject: [PATCH 18/30] Update actions/upload-artifact action to v3 (#53) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci-macos.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index 0057b8b..28b5da1 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -23,7 +23,7 @@ jobs: DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer - name: Upload test artifacts if: failure() - uses: actions/upload-artifact@v2.2.3 + uses: actions/upload-artifact@v3.1.2 with: name: test-artifacts-${{ matrix.xcode }}-${{ github.run_id }} path: | @@ -43,7 +43,7 @@ jobs: DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer - name: Upload build artifacts if: failure() - uses: actions/upload-artifact@v2.2.3 + uses: actions/upload-artifact@v3.1.2 with: name: build-artifacts-${{ matrix.xcode }}-${{ github.run_id }} path: | From 50e5256e7a5af2b835c6de46e77cb0b6cf3a7b83 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 20 Apr 2023 07:35:16 +0000 Subject: [PATCH 19/30] Update codecov/codecov-action action to v3 (#54) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci-linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 206a21f..8ffdf76 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -30,7 +30,7 @@ jobs: - name: Generate coverage report run: llvm-cov export -format="lcov" .build/debug/*PackageTests.xctest -instr-profile .build/debug/codecov/default.profdata > coverage.lcov - name: Upload code coverage report - uses: codecov/codecov-action@v1.5.2 + uses: codecov/codecov-action@v3.1.2 with: token: ${{secrets.CODECOV_TOKEN}} file: coverage.lcov From 88dc088cb79d54def43439256983d6a4d92a5d6d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 21 Apr 2023 07:36:02 +0200 Subject: [PATCH 20/30] Update codecov/codecov-action action to v3.1.3 (#55) --- .github/workflows/ci-linux.yml | 2 +- .github/workflows/ci-macos.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 8ffdf76..34682c5 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -30,7 +30,7 @@ jobs: - name: Generate coverage report run: llvm-cov export -format="lcov" .build/debug/*PackageTests.xctest -instr-profile .build/debug/codecov/default.profdata > coverage.lcov - name: Upload code coverage report - uses: codecov/codecov-action@v3.1.2 + uses: codecov/codecov-action@v3.1.3 with: token: ${{secrets.CODECOV_TOKEN}} file: coverage.lcov diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index 28b5da1..43e7ce4 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -32,7 +32,7 @@ jobs: - name: Generate coverage report run: xcrun llvm-cov export -format="lcov" .build/debug/*PackageTests.xctest/Contents/MacOS/*PackageTests -instr-profile .build/debug/codecov/default.profdata > coverage.lcov - name: Upload code coverage report - uses: codecov/codecov-action@v3.1.2 + uses: codecov/codecov-action@v3.1.3 with: token: ${{secrets.CODECOV_TOKEN}} file: coverage.lcov From 7ad5a96f160a790f17471c2f0d5d57d5b03949b9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 8 May 2023 18:39:25 +0200 Subject: [PATCH 21/30] Update swiftwasm/swiftwasm-action action to v5.8 (#56) --- .github/workflows/ci-wasm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-wasm.yml b/.github/workflows/ci-wasm.yml index 9678910..2c634b3 100644 --- a/.github/workflows/ci-wasm.yml +++ b/.github/workflows/ci-wasm.yml @@ -12,6 +12,6 @@ jobs: steps: - uses: actions/checkout@v3 - name: Build - uses: swiftwasm/swiftwasm-action@v5.7 + uses: swiftwasm/swiftwasm-action@v5.8 with: shell-action: swift build --triple wasm32-unknown-wasi From a5c98c49635342d00f58506b7ad849715325ac5e Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Wed, 9 Oct 2024 14:30:55 +0200 Subject: [PATCH 22/30] Dependency updates 2024-10 (#65) * Update actions/checkout action to v4 * Update swiftwasm/swiftwasm-action action to v5.9 * Update codecov/codecov-action action to v4 * Update actions/upload-artifact action to v4 * Accumulate all non-major dependency updates into one pull request * Update CI Xcode versions * Update pipeline * Swift 5.10 on windows * Upload test failure artifacts * Debug linux CI * Always * Swift test help line comment * Linux testing * Linux testing * Upload artifacts * Include hidden files * Update testing * Update tests * Skip some performance tests on non Mac machines * Remove XCTestManifest files * Fix codecov on macOS --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci-linux.yml | 38 +- .github/workflows/ci-macos.yml | 41 +- .github/workflows/ci-wasm.yml | 4 +- .github/workflows/ci-windows.yml | 32 +- .../HashingPerformanceTests.swift | 4 + .../TypeIdentifierPerformanceTests.swift | 6 +- .../XCTestManifests.swift | 70 --- Tests/FirebladeECSTests/XCTestManifests.swift | 454 ------------------ Tests/LinuxMain.swift | 10 - renovate.json | 11 +- 10 files changed, 78 insertions(+), 592 deletions(-) delete mode 100644 Tests/FirebladeECSPerformanceTests/XCTestManifests.swift delete mode 100644 Tests/FirebladeECSTests/XCTestManifests.swift delete mode 100644 Tests/LinuxMain.swift diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 34682c5..6e5dd19 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -16,24 +16,24 @@ jobs: image: swift:${{ matrix.swift }} steps: - name: Checkout - uses: actions/checkout@v3 - - name: "Update APT" - shell: bash - run: "apt update" - - name: "Install curl" - shell: bash - run: "apt-get install -y curl" - - name: Swift version - run: swift --version + uses: actions/checkout@v4 + - name: Test - run: swift test -v --skip-update --parallel --enable-test-discovery --enable-code-coverage - - name: Generate coverage report - run: llvm-cov export -format="lcov" .build/debug/*PackageTests.xctest -instr-profile .build/debug/codecov/default.profdata > coverage.lcov - - name: Upload code coverage report - uses: codecov/codecov-action@v3.1.3 + run: swift test -c release --enable-xctest --parallel --xunit-output .build/xUnit-output.xml + + - name: Upload test artifacts + if: failure() + uses: actions/upload-artifact@v4.4.2 with: - token: ${{secrets.CODECOV_TOKEN}} - file: coverage.lcov - fail_ci_if_error: true - - name: Build Release - run: swift build -c release + name: test-artifacts-linux-${{ matrix.swift }}-${{ github.run_id }} + path: | + .build/*.yaml + .build/*.xml + .build/*.json + .build/*.txt + .build/**/*.xctest + .build/**/*.json + .build/**/*.txt + if-no-files-found: warn + include-hidden-files: true + diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index 43e7ce4..e42882c 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -11,46 +11,37 @@ jobs: runs-on: macOS-latest strategy: matrix: - xcode: ["13.4.1", "14.2"] + xcode: ["14.3.1", "15.4", "16.0"] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Select Xcode ${{ matrix.xcode }} run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app - name: Test - run: swift test -v --skip-update --parallel --enable-test-discovery --enable-code-coverage + run: swift test -c release --parallel --xunit-output .build/xUnit-output.xml --enable-code-coverage env: DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer - name: Upload test artifacts if: failure() - uses: actions/upload-artifact@v3.1.2 + uses: actions/upload-artifact@v4.4.2 with: name: test-artifacts-${{ matrix.xcode }}-${{ github.run_id }} path: | - .build/**/*.json + .build/*.yaml + .build/*.xml + .build/*.json + .build/*.txt .build/**/*.xctest + .build/**/*.json + .build/**/*.txt + if-no-files-found: warn + include-hidden-files: true + - name: Generate coverage report - run: xcrun llvm-cov export -format="lcov" .build/debug/*PackageTests.xctest/Contents/MacOS/*PackageTests -instr-profile .build/debug/codecov/default.profdata > coverage.lcov + run: xcrun llvm-cov export -format="lcov" .build/**/*PackageTests.xctest/Contents/MacOS/*PackageTests -instr-profile .build/**/codecov/default.profdata > coverage.lcov - name: Upload code coverage report - uses: codecov/codecov-action@v3.1.3 + uses: codecov/codecov-action@v4.6.0 with: - token: ${{secrets.CODECOV_TOKEN}} + token: ${{ secrets.CODECOV_TOKEN }} file: coverage.lcov fail_ci_if_error: true - - name: Build Release - run: swift build -c release - env: - DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer - - name: Upload build artifacts - if: failure() - uses: actions/upload-artifact@v3.1.2 - with: - name: build-artifacts-${{ matrix.xcode }}-${{ github.run_id }} - path: | - *.lcov - .build/*.yaml - .build/**/*.a - .build/**/*.so - .build/**/*.dylib - .build/**/*.dSYM - .build/**/*.json diff --git a/.github/workflows/ci-wasm.yml b/.github/workflows/ci-wasm.yml index 2c634b3..0af195b 100644 --- a/.github/workflows/ci-wasm.yml +++ b/.github/workflows/ci-wasm.yml @@ -10,8 +10,8 @@ jobs: wasm-build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build - uses: swiftwasm/swiftwasm-action@v5.8 + uses: swiftwasm/swiftwasm-action@v5.9 with: shell-action: swift build --triple wasm32-unknown-wasi diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index 0432d28..7614153 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -10,16 +10,30 @@ jobs: windows-test-build-release: runs-on: windows-latest steps: - - uses: compnerd/gha-setup-swift@main + - name: Setup + uses: compnerd/gha-setup-swift@v0.2.3 with: - branch: swift-5.7-release - tag: 5.7-RELEASE + branch: swift-5.10-release + tag: 5.10-RELEASE - name: Checkout - uses: actions/checkout@v3 - - - name: Test - run: swift test -v --skip-update --parallel --enable-test-discovery + uses: actions/checkout@v4 - - name: Build Release - run: swift build -c release + - name: Test + run: swift test -c release --parallel --xunit-output .build/xUnit-output.xml + + - name: Upload test artifacts + if: failure() + uses: actions/upload-artifact@v4.4.2 + with: + name: test-artifacts-windows-${{ github.run_id }} + path: | + .build/*.yaml + .build/*.xml + .build/*.json + .build/*.txt + .build/**/*.xctest + .build/**/*.json + .build/**/*.txt + if-no-files-found: warn + include-hidden-files: true diff --git a/Tests/FirebladeECSPerformanceTests/HashingPerformanceTests.swift b/Tests/FirebladeECSPerformanceTests/HashingPerformanceTests.swift index 8446ebf..5b64f5e 100644 --- a/Tests/FirebladeECSPerformanceTests/HashingPerformanceTests.swift +++ b/Tests/FirebladeECSPerformanceTests/HashingPerformanceTests.swift @@ -5,6 +5,7 @@ // Created by Christian Treffs on 14.02.19. // +#if os(macOS) import FirebladeECS import XCTest @@ -97,3 +98,6 @@ class HashingPerformanceTests: XCTestCase { #endif } } +#else + #warning("Skipping HashingPerformanceTests") +#endif diff --git a/Tests/FirebladeECSPerformanceTests/TypeIdentifierPerformanceTests.swift b/Tests/FirebladeECSPerformanceTests/TypeIdentifierPerformanceTests.swift index 661ee98..e073174 100644 --- a/Tests/FirebladeECSPerformanceTests/TypeIdentifierPerformanceTests.swift +++ b/Tests/FirebladeECSPerformanceTests/TypeIdentifierPerformanceTests.swift @@ -5,6 +5,7 @@ // Created by Christian Treffs on 05.10.19. // +#if os(macOS) import FirebladeECS import XCTest @@ -30,7 +31,7 @@ final class TypeIdentifierPerformanceTests: XCTestCase { /// release: 1.034 sec /// debug: func testPerformanceHash() { - measure { + measure(options: .default) { for _ in 0.. [XCTestCaseEntry] { - return [ - testCase(ComponentIdentifierTests.__allTests__ComponentIdentifierTests), - testCase(HashingPerformanceTests.__allTests__HashingPerformanceTests), - testCase(TypeIdentifierPerformanceTests.__allTests__TypeIdentifierPerformanceTests), - testCase(TypedFamilyPerformanceTests.__allTests__TypedFamilyPerformanceTests), - ] -} -#endif diff --git a/Tests/FirebladeECSTests/XCTestManifests.swift b/Tests/FirebladeECSTests/XCTestManifests.swift deleted file mode 100644 index 5b55420..0000000 --- a/Tests/FirebladeECSTests/XCTestManifests.swift +++ /dev/null @@ -1,454 +0,0 @@ -#if !canImport(ObjectiveC) -import XCTest - -extension ComponentIdentifierTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__ComponentIdentifierTests = [ - ("testMirrorAsStableIdentifier", testMirrorAsStableIdentifier), - ("testStringDescribingAsStableIdentifier", testStringDescribingAsStableIdentifier), - ] -} - -extension ComponentInstanceProviderTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__ComponentInstanceProviderTests = [ - ("testProviderReturnsTheInstance", testProviderReturnsTheInstance), - ("testProvidersWithDifferentInstanceHaveDifferentIdentifier", testProvidersWithDifferentInstanceHaveDifferentIdentifier), - ("testProvidersWithSameInstanceHaveSameIdentifier", testProvidersWithSameInstanceHaveSameIdentifier), - ] -} - -extension ComponentSingletonProviderTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__ComponentSingletonProviderTests = [ - ("testProviderReturnsAnInstanceOfType", testProviderReturnsAnInstanceOfType), - ("testProviderReturnsSameInstanceEachTime", testProviderReturnsSameInstanceEachTime), - ("testProvidersWithDifferentTypeHaveDifferentIdentifier", testProvidersWithDifferentTypeHaveDifferentIdentifier), - ("testProvidersWithSameTypeHaveDifferentIdentifier", testProvidersWithSameTypeHaveDifferentIdentifier), - ] -} - -extension ComponentTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__ComponentTests = [ - ("testComponentIdentifier", testComponentIdentifier), - ] -} - -extension ComponentTypeProviderTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__ComponentTypeProviderTests = [ - ("testProviderReturnsAnInstanceOfType", testProviderReturnsAnInstanceOfType), - ("testProviderReturnsNewInstanceEachTime", testProviderReturnsNewInstanceEachTime), - ("testProvidersWithDifferentTypeHaveDifferentIdentifier", testProvidersWithDifferentTypeHaveDifferentIdentifier), - ("testProvidersWithSameTypeHaveSameIdentifier", testProvidersWithSameTypeHaveSameIdentifier), - ] -} - -extension DynamicComponentProviderTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__DynamicComponentProviderTests = [ - ("testProviderReturnsTheInstance", testProviderReturnsTheInstance), - ("testProvidersWithDifferentMethodsHaveDifferentIdentifier", testProvidersWithDifferentMethodsHaveDifferentIdentifier), - ("testProvidersWithSameMethodHaveSameIdentifier", testProvidersWithSameMethodHaveSameIdentifier), - ] -} - -extension EntityCreationTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__EntityCreationTests = [ - ("testBulkCreateEntitiesMultipleComponents", testBulkCreateEntitiesMultipleComponents), - ("testBulkCreateEntitiesOneComponent", testBulkCreateEntitiesOneComponent), - ("testCreateEntityMultipleComponents", testCreateEntityMultipleComponents), - ("testCreateEntityOneComponent", testCreateEntityOneComponent), - ] -} - -extension EntityIdGenTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__EntityIdGenTests = [ - ("testGenerateWithInitialIds", testGenerateWithInitialIds), - ("testGeneratorDefaultInit", testGeneratorDefaultInit), - ("testGeneratorMarkUnused", testGeneratorMarkUnused), - ("testGeneratorWithDefaultEmptyCollection", testGeneratorWithDefaultEmptyCollection), - ("testLinearIncrement", testLinearIncrement), - ] -} - -extension EntityStateMachineTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__EntityStateMachineTests = [ - ("testCallChangeStateWithSameNameLeavesEntityComponentsIntact", testCallChangeStateWithSameNameLeavesEntityComponentsIntact), - ("testCreateStateAddsState", testCreateStateAddsState), - ("testCreateStateDoesNotChangeState", testCreateStateDoesNotChangeState), - ("testEnterSecondStateAddsSecondStatesComponents", testEnterSecondStateAddsSecondStatesComponents), - ("testEnterSecondStateDoesNotRemoveOverlappingComponents", testEnterSecondStateDoesNotRemoveOverlappingComponents), - ("testEnterSecondStateRemovesDifferentComponentsOfSameType", testEnterSecondStateRemovesDifferentComponentsOfSameType), - ("testEnterSecondStateRemovesFirstStatesComponents", testEnterSecondStateRemovesFirstStatesComponents), - ("testEnterStateAddsStatesComponents", testEnterStateAddsStatesComponents), - ("testGetsDeinitedWhileBeingStronglyReferencedByComponentAssignedToEntity", testGetsDeinitedWhileBeingStronglyReferencedByComponentAssignedToEntity), - ] -} - -extension EntityStateTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__EntityStateTests = [ - ("testAddInstanceCreatesMappingAndSetsInstanceProviderForInstanceType", testAddInstanceCreatesMappingAndSetsInstanceProviderForInstanceType), - ("testAddMappingWithInstanceQualifierCreatesInstanceProvider", testAddMappingWithInstanceQualifierCreatesInstanceProvider), - ("testAddMappingWithMethodQualifierCreatesDynamicProvider", testAddMappingWithMethodQualifierCreatesDynamicProvider), - ("testAddMappingWithNoQualifierCreatesTypeProvider", testAddMappingWithNoQualifierCreatesTypeProvider), - ("testAddMappingWithSingletonQualifierCreatesSingletonProvider", testAddMappingWithSingletonQualifierCreatesSingletonProvider), - ("testAddMappingWithTypeQualifierCreatesTypeProvider", testAddMappingWithTypeQualifierCreatesTypeProvider), - ("testAddMethodCreatesMappingAndSetsDynamicProviderForType", testAddMethodCreatesMappingAndSetsDynamicProviderForType), - ("testAddProviderCreatesMappingAndSetsProvider", testAddProviderCreatesMappingAndSetsProvider), - ("testAddSingletonCreatesMappingAndSetsSingletonProviderForType", testAddSingletonCreatesMappingAndSetsSingletonProviderForType), - ("testAddTypeCreatesMappingAndSetsTypeProviderForType", testAddTypeCreatesMappingAndSetsTypeProviderForType), - ("testHasProviderReturnsFalseForNotCreatedProvider", testHasProviderReturnsFalseForNotCreatedProvider), - ("testHasProviderReturnsTrueForCreatedProvider", testHasProviderReturnsTrueForCreatedProvider), - ("testProviderForTypeReturnsDynamicProvider", testProviderForTypeReturnsDynamicProvider), - ("testProviderForTypeReturnsInstanceProvider", testProviderForTypeReturnsInstanceProvider), - ("testProviderForTypeReturnsPassedProvider", testProviderForTypeReturnsPassedProvider), - ("testProviderForTypeReturnsSingletonProvider", testProviderForTypeReturnsSingletonProvider), - ("testProviderForTypeReturnsTypeProvider", testProviderForTypeReturnsTypeProvider), - ("testProviderForTypeReturnsTypeProviderByDefault", testProviderForTypeReturnsTypeProviderByDefault), - ] -} - -extension EntityTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__EntityTests = [ - ("testAllComponentsOfEntity", testAllComponentsOfEntity), - ("testComponentsIteration", testComponentsIteration), - ("testEntityCreationIntrinsic", testEntityCreationIntrinsic), - ("testEntityDescriptions", testEntityDescriptions), - ("testEntityEquality", testEntityEquality), - ("testEntityIdentifierAndIndex", testEntityIdentifierAndIndex), - ("testEntityIdGenerator", testEntityIdGenerator), - ("testEntitySubscripts", testEntitySubscripts), - ("testRemoveAllComponentsFromEntity", testRemoveAllComponentsFromEntity), - ] -} - -extension Family1Tests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__Family1Tests = [ - ("testComponentIteration", testComponentIteration), - ("testEntityComponentIteration", testEntityComponentIteration), - ("testEntityIteration", testEntityIteration), - ("testFamilyDecoding", testFamilyDecoding), - ("testFamilyEncoding", testFamilyEncoding), - ("testFamilyFailDecoding", testFamilyFailDecoding), - ("testMemberCreation", testMemberCreation), - ("testMemberCreationBuilder", testMemberCreationBuilder), - ] -} - -extension Family2Tests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__Family2Tests = [ - ("testComponentIteration", testComponentIteration), - ("testEntityComponentIteration", testEntityComponentIteration), - ("testEntityIteration", testEntityIteration), - ("testFamilyDecoding", testFamilyDecoding), - ("testFamilyEncoding", testFamilyEncoding), - ("testFamilyFailDecoding", testFamilyFailDecoding), - ("testMemberCreation", testMemberCreation), - ("testMemberCreationBuilder", testMemberCreationBuilder), - ] -} - -extension Family3Tests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__Family3Tests = [ - ("testComponentIteration", testComponentIteration), - ("testEntityComponentIteration", testEntityComponentIteration), - ("testEntityIteration", testEntityIteration), - ("testFamilyDecoding", testFamilyDecoding), - ("testFamilyEncoding", testFamilyEncoding), - ("testFamilyFailDecoding", testFamilyFailDecoding), - ("testMemberCreation", testMemberCreation), - ("testMemberCreationBuilder", testMemberCreationBuilder), - ] -} - -extension Family4Tests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__Family4Tests = [ - ("testComponentIteration", testComponentIteration), - ("testEntityComponentIteration", testEntityComponentIteration), - ("testEntityIteration", testEntityIteration), - ("testFamilyDecoding", testFamilyDecoding), - ("testFamilyEncoding", testFamilyEncoding), - ("testFamilyFailDecoding", testFamilyFailDecoding), - ("testMemberCreation", testMemberCreation), - ("testMemberCreationBuilder", testMemberCreationBuilder), - ] -} - -extension Family5Tests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__Family5Tests = [ - ("testComponentIteration", testComponentIteration), - ("testEntityComponentIteration", testEntityComponentIteration), - ("testEntityIteration", testEntityIteration), - ("testFamilyDecoding", testFamilyDecoding), - ("testFamilyEncoding", testFamilyEncoding), - ("testFamilyFailDecoding", testFamilyFailDecoding), - ("testMemberCreation", testMemberCreation), - ("testMemberCreationBuilder", testMemberCreationBuilder), - ] -} - -extension Family6Tests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__Family6Tests = [ - ("testComponentIteration", testComponentIteration), - ("testEntityComponentIteration", testEntityComponentIteration), - ("testEntityIteration", testEntityIteration), - ("testFamilyDecoding", testFamilyDecoding), - ("testFamilyEncoding", testFamilyEncoding), - ("testFamilyFailDecoding", testFamilyFailDecoding), - ("testMemberCreation", testMemberCreation), - ("testMemberCreationBuilder", testMemberCreationBuilder), - ] -} - -extension Family7Tests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__Family7Tests = [ - ("testComponentIteration", testComponentIteration), - ("testEntityComponentIteration", testEntityComponentIteration), - ("testEntityIteration", testEntityIteration), - ("testFamilyDecoding", testFamilyDecoding), - ("testFamilyEncoding", testFamilyEncoding), - ("testFamilyFailDecoding", testFamilyFailDecoding), - ("testMemberCreation", testMemberCreation), - ("testMemberCreationBuilder", testMemberCreationBuilder), - ] -} - -extension Family8Tests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__Family8Tests = [ - ("testComponentIteration", testComponentIteration), - ("testEntityComponentIteration", testEntityComponentIteration), - ("testEntityIteration", testEntityIteration), - ("testFamilyDecoding", testFamilyDecoding), - ("testFamilyEncoding", testFamilyEncoding), - ("testFamilyFailDecoding", testFamilyFailDecoding), - ("testMemberCreation", testMemberCreation), - ("testMemberCreationBuilder", testMemberCreationBuilder), - ] -} - -extension FamilyCodingTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__FamilyCodingTests = [ - ("testDecodeFamily4", testDecodeFamily4), - ("testDecodeFamily5", testDecodeFamily5), - ("testDecodingFamily1", testDecodingFamily1), - ("testDecodingFamily2", testDecodingFamily2), - ("testDecodingFamily3", testDecodingFamily3), - ("testEncodeFamily2", testEncodeFamily2), - ("testEncodeFamily3", testEncodeFamily3), - ("testEncodeFamily4", testEncodeFamily4), - ("testEncodeFamily5", testEncodeFamily5), - ("testEncodingFamily1", testEncodingFamily1), - ("testFailDecodingFamily", testFailDecodingFamily), - ] -} - -extension FamilyTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__FamilyTests = [ - ("testFamilyAbandoned", testFamilyAbandoned), - ("testFamilyBulkDestroy", testFamilyBulkDestroy), - ("testFamilyCreateMembers", testFamilyCreateMembers), - ("testFamilyCreation", testFamilyCreation), - ("testFamilyDestroyMembers", testFamilyDestroyMembers), - ("testFamilyExchange", testFamilyExchange), - ("testFamilyLateMember", testFamilyLateMember), - ("testFamilyMemberBasicIteration", testFamilyMemberBasicIteration), - ("testFamilyReuse", testFamilyReuse), - ] -} - -extension FamilyTraitsTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__FamilyTraitsTests = [ - ("testTraitCommutativity", testTraitCommutativity), - ("testTraitMatching", testTraitMatching), - ] -} - -extension HashingTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__HashingTests = [ - ("testCollisionsInCritialRange", testCollisionsInCritialRange), - ("testStringHashes", testStringHashes), - ] -} - -extension NexusEventDelegateTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__NexusEventDelegateTests = [ - ("testEventComponentAdded", testEventComponentAdded), - ("testEventComponentRemoved", testEventComponentRemoved), - ("testEventEntityCreated", testEventEntityCreated), - ("testEventEntityDestroyed", testEventEntityDestroyed), - ("testFamilyMemberRemoved", testFamilyMemberRemoved), - ("testFamilyMemeberAdded", testFamilyMemeberAdded), - ] -} - -extension NexusTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__NexusTests = [ - ("testComponentCreation", testComponentCreation), - ("testComponentDeletion", testComponentDeletion), - ("testComponentRetrieval", testComponentRetrieval), - ("testComponentUniqueness", testComponentUniqueness), - ("testEntityCreate", testEntityCreate), - ("testEntityDestroy", testEntityDestroy), - ("testEntityIteration", testEntityIteration), - ] -} - -extension SingleTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__SingleTests = [ - ("testSingleCreation", testSingleCreation), - ("testSingleCreationOnExistingFamilyMember", testSingleCreationOnExistingFamilyMember), - ("testSingleEntityAndComponentCreation", testSingleEntityAndComponentCreation), - ("testSingleReuse", testSingleReuse), - ] -} - -extension SparseSetTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__SparseSetTests = [ - ("testAlternativeKey", testAlternativeKey), - ("testEquality", testEquality), - ("testSparseSetAdd", testSparseSetAdd), - ("testSparseSetAddAndReplace", testSparseSetAddAndReplace), - ("testSparseSetClear", testSparseSetClear), - ("testSparseSetDoubleRemove", testSparseSetDoubleRemove), - ("testSparseSetGet", testSparseSetGet), - ("testSparseSetNonCongiuousData", testSparseSetNonCongiuousData), - ("testSparseSetReduce", testSparseSetReduce), - ("testSparseSetRemove", testSparseSetRemove), - ("testSparseSetRemoveAndAdd", testSparseSetRemoveAndAdd), - ("testSparseSetRemoveNonPresent", testSparseSetRemoveNonPresent), - ("testStartEndIndex", testStartEndIndex), - ("testSubscript", testSubscript), - ] -} - -extension StateComponentMappingTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__StateComponentMappingTests = [ - ("testAddAddsProviderToState", testAddAddsProviderToState), - ("testAddReturnsSameMappingForDifferentComponentTypes", testAddReturnsSameMappingForDifferentComponentTypes), - ("testAddReturnsSameMappingForSameComponentType", testAddReturnsSameMappingForSameComponentType), - ] -} - -extension SystemsTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__SystemsTests = [ - ("testSystemsUpdate", testSystemsUpdate), - ] -} - -public func __allTests() -> [XCTestCaseEntry] { - return [ - testCase(ComponentIdentifierTests.__allTests__ComponentIdentifierTests), - testCase(ComponentInstanceProviderTests.__allTests__ComponentInstanceProviderTests), - testCase(ComponentSingletonProviderTests.__allTests__ComponentSingletonProviderTests), - testCase(ComponentTests.__allTests__ComponentTests), - testCase(ComponentTypeProviderTests.__allTests__ComponentTypeProviderTests), - testCase(DynamicComponentProviderTests.__allTests__DynamicComponentProviderTests), - testCase(EntityCreationTests.__allTests__EntityCreationTests), - testCase(EntityIdGenTests.__allTests__EntityIdGenTests), - testCase(EntityStateMachineTests.__allTests__EntityStateMachineTests), - testCase(EntityStateTests.__allTests__EntityStateTests), - testCase(EntityTests.__allTests__EntityTests), - testCase(Family1Tests.__allTests__Family1Tests), - testCase(Family2Tests.__allTests__Family2Tests), - testCase(Family3Tests.__allTests__Family3Tests), - testCase(Family4Tests.__allTests__Family4Tests), - testCase(Family5Tests.__allTests__Family5Tests), - testCase(Family6Tests.__allTests__Family6Tests), - testCase(Family7Tests.__allTests__Family7Tests), - testCase(Family8Tests.__allTests__Family8Tests), - testCase(FamilyCodingTests.__allTests__FamilyCodingTests), - testCase(FamilyTests.__allTests__FamilyTests), - testCase(FamilyTraitsTests.__allTests__FamilyTraitsTests), - testCase(HashingTests.__allTests__HashingTests), - testCase(NexusEventDelegateTests.__allTests__NexusEventDelegateTests), - testCase(NexusTests.__allTests__NexusTests), - testCase(SingleTests.__allTests__SingleTests), - testCase(SparseSetTests.__allTests__SparseSetTests), - testCase(StateComponentMappingTests.__allTests__StateComponentMappingTests), - testCase(SystemsTests.__allTests__SystemsTests), - ] -} -#endif diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift deleted file mode 100644 index 7889cf4..0000000 --- a/Tests/LinuxMain.swift +++ /dev/null @@ -1,10 +0,0 @@ -import XCTest - -import FirebladeECSPerformanceTests -import FirebladeECSTests - -var tests = [XCTestCaseEntry]() -tests += FirebladeECSPerformanceTests.__allTests() -tests += FirebladeECSTests.__allTests() - -XCTMain(tests) diff --git a/renovate.json b/renovate.json index 39a2b6e..e6838fd 100644 --- a/renovate.json +++ b/renovate.json @@ -1,6 +1,13 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": [ - "config:base" + "extends": ["config:base"], + "packageRules": [ + { + "description": "Accumulate non-major updates into one pull request", + "matchUpdateTypes": ["minor", "patch"], + "matchCurrentVersion": ">=1", + "groupName": "all non-major dependencies", + "groupSlug": "all-minor-patch" + } ] } From 2c1c5885aed6951834cabf359c499b6f7ea68300 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Wed, 9 Oct 2024 17:08:12 +0200 Subject: [PATCH 23/30] Modernize project (#66) * Add Mintfile * Update Makefile * Use old swiftlint and swiftformat versions * Lint * Update SwiftLint and SwiftFormat Versions + Lint * Re-add documented make rules * Update sourcery to 2.2.5 * Update SwiftLint and Lint --- .swiftformat | 11 ++ .swiftlint.yml | 23 +--- Makefile | 108 ++++++++---------- Mintfile | 3 + Sources/FirebladeECS/CodingStrategy.swift | 2 +- .../FirebladeECS/ComponentIdentifier.swift | 8 +- Sources/FirebladeECS/Entity.swift | 11 +- Sources/FirebladeECS/EntityIdentifier.swift | 6 +- .../EntityIdentifierGenerator.swift | 6 +- Sources/FirebladeECS/FSM.swift | 11 +- Sources/FirebladeECS/Family+Coding.swift | 4 +- Sources/FirebladeECS/Family.swift | 26 +++-- .../FirebladeECS/FamilyMemberBuilder.swift | 8 +- Sources/FirebladeECS/FamilyTraitSet.swift | 2 +- .../FirebladeECS/Foundation+Extensions.swift | 6 +- .../Generated/Family.generated.swift | 3 +- Sources/FirebladeECS/Hashing.swift | 17 +-- .../FirebladeECS/ManagedContiguousArray.swift | 4 +- Sources/FirebladeECS/Nexus+Component.swift | 2 +- .../Nexus+ComponentsBuilder.swift | 16 +-- Sources/FirebladeECS/Nexus+Entity.swift | 10 +- Sources/FirebladeECS/Nexus+Internal.swift | 2 +- Sources/FirebladeECS/Nexus.swift | 17 +-- Sources/FirebladeECS/NexusEvent.swift | 2 +- Sources/FirebladeECS/Single.swift | 2 +- Sources/FirebladeECS/UnorderedSparseSet.swift | 22 ++-- .../Generated/FamilyTests.generated.swift | 3 +- 27 files changed, 168 insertions(+), 167 deletions(-) create mode 100644 .swiftformat create mode 100644 Mintfile diff --git a/.swiftformat b/.swiftformat new file mode 100644 index 0000000..72f3230 --- /dev/null +++ b/.swiftformat @@ -0,0 +1,11 @@ +# file options +--exclude Sources/**/*.generated.swift +--exclude Sources/FirebladeECS/Entity+Component.swift # problems with self.get { } +--exclude Tests/**/*.swift + +# format options +--extensionacl on-declarations +--stripunusedargs closure-only +--commas inline +--self remove +--selfrequired get \ No newline at end of file diff --git a/.swiftlint.yml b/.swiftlint.yml index cfc6611..e32b7d4 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -9,23 +9,11 @@ identifier_name: line_length: 220 number_separator: minimum_length: 5 +analyzer_rules: + - explicit_self + - unused_declaration + - unused_import opt_in_rules: - #- explicit_acl - #- explicit_enum_raw_value - #- explicit_type_interface - #- extension_access_modifier - #- file_name - #- file_types_order - #- indentation_width - #- missing_docs - #- multiline_arguments_brackets - #- multiline_literal_brackets - #- multiline_parameters_brackets - #- no_grouping_extension - #- required_deinit - #- type_contents_order - #- unowned_variable_capture - - anyobject_protocol - array_init - attributes - closure_body_length @@ -48,7 +36,6 @@ opt_in_rules: - enum_case_associated_values_count - expiring_todo - explicit_init - - explicit_self - explicit_top_level_acl - fallthrough - fatal_error_message @@ -109,8 +96,6 @@ opt_in_rules: - unavailable_function - unneeded_parentheses_in_closure_argument - untyped_error_in_catch - - unused_declaration - - unused_import - vertical_parameter_alignment_on_call - vertical_whitespace_between_cases - vertical_whitespace_closing_braces diff --git a/Makefile b/Makefile index ecb7109..7518a32 100644 --- a/Makefile +++ b/Makefile @@ -1,79 +1,61 @@ -# Version 1.0.0 -UNAME_S := $(shell uname -s) +SWIFT_PACKAGE_VERSION := $(shell swift package tools-version) -# Lint -lint: - swiftlint autocorrect --format - swiftlint lint --quiet +# Lint fix and format code. +.PHONY: lint-fix +swiftlint: + mint run swiftlint lint --fix --config .swiftlint.yml --format --quiet +swiftformat: + mint run swiftformat . --swiftversion ${SWIFT_PACKAGE_VERSION} +lint-fix: swiftlint swiftformat -lintErrorOnly: - @swiftlint autocorrect --format --quiet - @swiftlint lint --quiet | grep error +# Generate code +.PHONY: generate-code +generate-code: + mint run sourcery --quiet --config ./.sourcery.yml + mint run sourcery --quiet --config ./.sourceryTests.yml -# Git -precommit: generateCode generateTestsCode lint genLinuxTests +# Run pre-push tasks +.PHONY: pre-push +pre-push: generate-code lint-fix -submodule: - git submodule init - git submodule update --recursive +.PHONY: precommit +precommit: pre-push -# Tests -genLinuxTests: - swift test --generate-linuxmain - swiftlint autocorrect --format --path Tests/ +.PHONY: setup-brew +setup-brew: + @which -s brew || /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" + @brew update -test: genLinuxTests - swift test +.PHONY: install-dependencies-macOS +install-dependencies-macOS: setup-brew + brew install mint + mint bootstrap -# Package -latest: - swift package update +.PHONY: setupEnvironment +setupEnvironment: install-dependencies-macOS -resolve: - swift package resolve +# Build debug version +.PHONY: build-debug +build-debug: + swift build -c debug -# Xcode -genXcode: - swift package generate-xcodeproj --enable-code-coverage --skip-extra-files - -genXcodeOpen: genXcode - open *.xcodeproj - -# Clean -clean: - swift package reset - -rm -rdf .swiftpm/xcode - -rm -rdf .build/ - -rm Package.resolved - -rm .DS_Store - -cleanArtifacts: - swift package clean +# Build release version +.PHONY: build-release +build-release: + swift build -c release --skip-update # Test links in README # requires +.PHONY: testReadme testReadme: markdown-link-check -p -v ./README.md -generateCode: - sourcery --config ./.sourcery.yml --verbose -generateTestsCode: - sourcery --config ./.sourceryTests.yml --verbose +# Delete package build artifacts. +.PHONY: clean +clean: clean-sourcery + swift package clean -brewInstallDeps: brewUpdate - brew install swiftenv - brew install swiftlint - brew install sourcery - -brewSetup: - which -s brew || /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" - -brewUpdate: brewSetup - brew update - -setupEnvironment: brewInstallDeps - open Package.swift - -# lines of code -loc: clean - find . -name "*.swift" -print0 | xargs -0 wc -l +# Clean sourcery cache +.PHONY: clean-sourcery +clean-sourcery: + rm -rdf ${HOME}/Library/Caches/Sourcery diff --git a/Mintfile b/Mintfile new file mode 100644 index 0000000..cf6a988 --- /dev/null +++ b/Mintfile @@ -0,0 +1,3 @@ +realm/SwiftLint@0.57.0 +nicklockwood/SwiftFormat@0.54.6 +krzysztofzablocki/Sourcery@2.2.5 diff --git a/Sources/FirebladeECS/CodingStrategy.swift b/Sources/FirebladeECS/CodingStrategy.swift index 5b89848..1790637 100644 --- a/Sources/FirebladeECS/CodingStrategy.swift +++ b/Sources/FirebladeECS/CodingStrategy.swift @@ -13,6 +13,6 @@ public struct DynamicCodingKey: CodingKey { public var intValue: Int? public var stringValue: String - public init?(intValue: Int) { self.intValue = intValue; self.stringValue = "\(intValue)" } + public init?(intValue: Int) { self.intValue = intValue; stringValue = "\(intValue)" } public init?(stringValue: String) { self.stringValue = stringValue } } diff --git a/Sources/FirebladeECS/ComponentIdentifier.swift b/Sources/FirebladeECS/ComponentIdentifier.swift index 72fc9e5..9a7a5d2 100644 --- a/Sources/FirebladeECS/ComponentIdentifier.swift +++ b/Sources/FirebladeECS/ComponentIdentifier.swift @@ -14,14 +14,14 @@ public struct ComponentIdentifier { extension ComponentIdentifier { @usableFromInline init(_ componentType: C.Type) where C: Component { - self.id = Self.makeRuntimeHash(componentType) + id = Self.makeRuntimeHash(componentType) } /// object identifier hash (only stable during runtime) - arbitrary hash is ok. - internal static func makeRuntimeHash(_ componentType: C.Type) -> Identifier where C: Component { + static func makeRuntimeHash(_ componentType: C.Type) -> Identifier where C: Component { ObjectIdentifier(componentType).hashValue } } -extension ComponentIdentifier: Equatable { } -extension ComponentIdentifier: Hashable { } +extension ComponentIdentifier: Equatable {} +extension ComponentIdentifier: Hashable {} diff --git a/Sources/FirebladeECS/Entity.swift b/Sources/FirebladeECS/Entity.swift index 33e3ff2..5601834 100644 --- a/Sources/FirebladeECS/Entity.swift +++ b/Sources/FirebladeECS/Entity.swift @@ -17,9 +17,9 @@ public struct Entity { /// The unique entity identifier. public private(set) var identifier: EntityIdentifier - internal init(nexus: Nexus, id: EntityIdentifier) { + init(nexus: Nexus, id: EntityIdentifier) { self.nexus = nexus - self.identifier = id + identifier = id } /// Returns the number of components for this entity. @@ -130,7 +130,7 @@ public struct Entity { extension Entity { public struct ComponentsIterator: IteratorProtocol { - private var iterator: IndexingIterator<([Component])>? + private var iterator: IndexingIterator<[Component]>? @usableFromInline init(nexus: Nexus, entityIdentifier: EntityIdentifier) { @@ -144,8 +144,9 @@ extension Entity { } } } -extension Entity.ComponentsIterator: LazySequenceProtocol { } -extension Entity.ComponentsIterator: Sequence { } + +extension Entity.ComponentsIterator: LazySequenceProtocol {} +extension Entity.ComponentsIterator: Sequence {} extension Entity: Equatable { public static func == (lhs: Entity, rhs: Entity) -> Bool { diff --git a/Sources/FirebladeECS/EntityIdentifier.swift b/Sources/FirebladeECS/EntityIdentifier.swift index 6c2e98e..f8676b6 100644 --- a/Sources/FirebladeECS/EntityIdentifier.swift +++ b/Sources/FirebladeECS/EntityIdentifier.swift @@ -23,8 +23,8 @@ public struct EntityIdentifier { } } -extension EntityIdentifier: Equatable { } -extension EntityIdentifier: Hashable { } +extension EntityIdentifier: Equatable {} +extension EntityIdentifier: Hashable {} extension EntityIdentifier: RawRepresentable { /// The entity identifier represented as a raw value. @@ -33,7 +33,7 @@ extension EntityIdentifier: RawRepresentable { @inlinable public init(rawValue: Identifier) { - self.id = rawValue + id = rawValue } } diff --git a/Sources/FirebladeECS/EntityIdentifierGenerator.swift b/Sources/FirebladeECS/EntityIdentifierGenerator.swift index 1c9a035..39a12f3 100644 --- a/Sources/FirebladeECS/EntityIdentifierGenerator.swift +++ b/Sources/FirebladeECS/EntityIdentifierGenerator.swift @@ -52,7 +52,7 @@ public struct LinearIncrementingEntityIdGenerator: EntityIdentifierGenerator { let initialInUse: [EntityIdentifier.Identifier] = initialEntityIds.map { $0.id } let maxInUseValue = initialInUse.max() ?? 0 let inUseSet = Set(initialInUse) // a set of all eIds in use - let allSet = Set(0...maxInUseValue) // all eIds from 0 to including maxInUseValue + let allSet = Set(0 ... maxInUseValue) // all eIds from 0 to including maxInUseValue let freeSet = allSet.subtracting(inUseSet) // all "holes" / unused / free eIds let initialFree = Array(freeSet).sorted().reversed() // order them to provide them linear increasing after all initially used are provided. stack = initialFree + initialInUse @@ -83,12 +83,12 @@ public struct LinearIncrementingEntityIdGenerator: EntityIdentifierGenerator { @inlinable public init(startProviding initialEntityIds: EntityIds) where EntityIds: BidirectionalCollection, EntityIds.Element == EntityIdentifier { - self.storage = Storage(startProviding: initialEntityIds) + storage = Storage(startProviding: initialEntityIds) } @inlinable public init() { - self.storage = Storage() + storage = Storage() } @inline(__always) diff --git a/Sources/FirebladeECS/FSM.swift b/Sources/FirebladeECS/FSM.swift index 9a8de0d..c33790b 100644 --- a/Sources/FirebladeECS/FSM.swift +++ b/Sources/FirebladeECS/FSM.swift @@ -97,9 +97,7 @@ extension ComponentTypeProvider: ComponentProvider { /// This component provider always returns the same instance of the component. The instance /// is created when first required and is of the type passed in to the initializer. public final class ComponentSingletonProvider { - private lazy var instance: Component = { - componentType.init() - }() + private lazy var instance: Component = componentType.init() private var componentType: ComponentInitializable.Type @@ -171,7 +169,7 @@ extension DynamicComponentProvider: ComponentProvider { /// Represents a state for an EntityStateMachine. The state contains any number of ComponentProviders which /// are used to add components to the entity when this state is entered. public class EntityState { - internal var providers = [ComponentIdentifier: ComponentProvider]() + var providers = [ComponentIdentifier: ComponentProvider]() public init() {} @@ -272,7 +270,7 @@ public class StateComponentMapping { /// by more specific mappings if other methods are called. /// - Parameter creatingState: The EntityState that the mapping will belong to /// - Parameter type: The component type for the mapping - internal init(creatingState: EntityState, type: ComponentInitializable.Type) { + init(creatingState: EntityState, type: ComponentInitializable.Type) { self.creatingState = creatingState componentType = type provider = ComponentTypeProvider(type: type) @@ -411,7 +409,8 @@ public class EntityStateMachine { for (identifier, _) in currentState.providers { if let other = toAdd[identifier], let current = currentState.providers[identifier], - current.identifier == other.identifier { + current.identifier == other.identifier + { toAdd[identifier] = nil } else { entity.remove(identifier) diff --git a/Sources/FirebladeECS/Family+Coding.swift b/Sources/FirebladeECS/Family+Coding.swift index 8de8699..1048d07 100644 --- a/Sources/FirebladeECS/Family+Coding.swift +++ b/Sources/FirebladeECS/Family+Coding.swift @@ -14,6 +14,7 @@ extension CodingUserInfoKey { } // MARK: - encoding + extension FamilyMemberContainer: Encodable where R: FamilyEncoding { func encode(to encoder: Encoder) throws { let strategy = encoder.userInfo[.nexusCodingStrategy] as? CodingStrategy ?? DefaultCodingStrategy() @@ -50,11 +51,12 @@ extension Family where R: FamilyEncoding { } // MARK: - decoding + extension FamilyMemberContainer: Decodable where R: FamilyDecoding { init(from decoder: Decoder) throws { var familyContainer = try decoder.unkeyedContainer() let strategy = decoder.userInfo[.nexusCodingStrategy] as? CodingStrategy ?? DefaultCodingStrategy() - self.components = try R.decode(componentsIn: &familyContainer, using: strategy) + components = try R.decode(componentsIn: &familyContainer, using: strategy) } } diff --git a/Sources/FirebladeECS/Family.swift b/Sources/FirebladeECS/Family.swift index ba5749e..9b2f13d 100644 --- a/Sources/FirebladeECS/Family.swift +++ b/Sources/FirebladeECS/Family.swift @@ -53,7 +53,7 @@ public struct Family where R: FamilyRequirementsManaging { /// - Returns: The newly created member entity. @discardableResult public func createMember(@FamilyMemberBuilder using builder: () -> R.Components) -> Entity { - self.createMember(with: builder()) + createMember(with: builder()) } } @@ -70,16 +70,17 @@ extension Family: Sequence { } } -extension Family: LazySequenceProtocol { } +extension Family: LazySequenceProtocol {} // MARK: - components iterator + extension Family { public struct ComponentsIterator: IteratorProtocol { @usableFromInline var memberIdsIterator: UnorderedSparseSet.ElementIterator @usableFromInline unowned let nexus: Nexus public init(family: Family) { - self.nexus = family.nexus + nexus = family.nexus memberIdsIterator = family.memberIds.makeIterator() } @@ -93,10 +94,11 @@ extension Family { } } -extension Family.ComponentsIterator: LazySequenceProtocol { } -extension Family.ComponentsIterator: Sequence { } +extension Family.ComponentsIterator: LazySequenceProtocol {} +extension Family.ComponentsIterator: Sequence {} // MARK: - entity iterator + extension Family { @inlinable public var entities: EntityIterator { EntityIterator(family: self) @@ -107,7 +109,7 @@ extension Family { @usableFromInline unowned let nexus: Nexus public init(family: Family) { - self.nexus = family.nexus + nexus = family.nexus memberIdsIterator = family.memberIds.makeIterator() } @@ -120,10 +122,11 @@ extension Family { } } -extension Family.EntityIterator: LazySequenceProtocol { } -extension Family.EntityIterator: Sequence { } +extension Family.EntityIterator: LazySequenceProtocol {} +extension Family.EntityIterator: Sequence {} // MARK: - entity component iterator + extension Family { @inlinable public var entityAndComponents: EntityComponentIterator { EntityComponentIterator(family: self) @@ -134,7 +137,7 @@ extension Family { @usableFromInline unowned let nexus: Nexus public init(family: Family) { - self.nexus = family.nexus + nexus = family.nexus memberIdsIterator = family.memberIds.makeIterator() } @@ -147,10 +150,11 @@ extension Family { } } -extension Family.EntityComponentIterator: LazySequenceProtocol { } -extension Family.EntityComponentIterator: Sequence { } +extension Family.EntityComponentIterator: LazySequenceProtocol {} +extension Family.EntityComponentIterator: Sequence {} // MARK: - member creation + extension Family { /// Create a new entity with components required by this family. /// diff --git a/Sources/FirebladeECS/FamilyMemberBuilder.swift b/Sources/FirebladeECS/FamilyMemberBuilder.swift index 044cc54..1d281fd 100644 --- a/Sources/FirebladeECS/FamilyMemberBuilder.swift +++ b/Sources/FirebladeECS/FamilyMemberBuilder.swift @@ -6,9 +6,9 @@ // #if swift(<5.4) -@_functionBuilder -public enum FamilyMemberBuilder where R: FamilyRequirementsManaging { } + @_functionBuilder + public enum FamilyMemberBuilder where R: FamilyRequirementsManaging {} #else -@resultBuilder -public enum FamilyMemberBuilder where R: FamilyRequirementsManaging { } + @resultBuilder + public enum FamilyMemberBuilder where R: FamilyRequirementsManaging {} #endif diff --git a/Sources/FirebladeECS/FamilyTraitSet.swift b/Sources/FirebladeECS/FamilyTraitSet.swift index 3da947e..8da4a2e 100644 --- a/Sources/FirebladeECS/FamilyTraitSet.swift +++ b/Sources/FirebladeECS/FamilyTraitSet.swift @@ -19,7 +19,7 @@ public struct FamilyTraitSet { self.requiresAll = requiresAll self.excludesAll = excludesAll - self.setHash = FirebladeECS.hash(combine: [requiresAll, excludesAll]) + setHash = FirebladeECS.hash(combine: [requiresAll, excludesAll]) } @inlinable diff --git a/Sources/FirebladeECS/Foundation+Extensions.swift b/Sources/FirebladeECS/Foundation+Extensions.swift index c7ff0cf..4ae06f1 100644 --- a/Sources/FirebladeECS/Foundation+Extensions.swift +++ b/Sources/FirebladeECS/Foundation+Extensions.swift @@ -6,8 +6,8 @@ // #if canImport(Foundation) -import Foundation + import Foundation -extension JSONEncoder: TopLevelEncoder { } -extension JSONDecoder: TopLevelDecoder { } + extension JSONEncoder: TopLevelEncoder {} + extension JSONDecoder: TopLevelDecoder {} #endif diff --git a/Sources/FirebladeECS/Generated/Family.generated.swift b/Sources/FirebladeECS/Generated/Family.generated.swift index caa2ff2..00d67e4 100644 --- a/Sources/FirebladeECS/Generated/Family.generated.swift +++ b/Sources/FirebladeECS/Generated/Family.generated.swift @@ -1,6 +1,5 @@ -// Generated using Sourcery 1.0.0 — https://github.com/krzysztofzablocki/Sourcery +// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery // DO NOT EDIT - // swiftlint:disable file_length // swiftlint:disable function_parameter_count // swiftlint:disable large_tuple diff --git a/Sources/FirebladeECS/Hashing.swift b/Sources/FirebladeECS/Hashing.swift index d319029..033b946 100644 --- a/Sources/FirebladeECS/Hashing.swift +++ b/Sources/FirebladeECS/Hashing.swift @@ -6,11 +6,11 @@ // #if arch(x86_64) || arch(arm64) || arch(powerpc64) || arch(powerpc64le) || arch(s390x) // 64 bit -private let kFibA: UInt = 0x9e3779b97f4a7c15 // = 11400714819323198485 aka Fibonacci Hash a value for 2^64; calculate by: 2^64 / (golden ratio) + private let kFibA: UInt = 0x9E37_79B9_7F4A_7C15 // = 11400714819323198485 aka Fibonacci Hash a value for 2^64; calculate by: 2^64 / (golden ratio) #elseif arch(i386) || arch(arm) || os(watchOS) || arch(wasm32) // 32 bit -private let kFibA: UInt = 0x9e3779b9 // = 2654435769 aka Fibonacci Hash a value for 2^32; calculate by: 2^32 / (golden ratio) + private let kFibA: UInt = 0x9E37_79B9 // = 2654435769 aka Fibonacci Hash a value for 2^32; calculate by: 2^32 / (golden ratio) #else -#error("unsupported architecture") + #error("unsupported architecture") #endif /// entity id ^ component identifier hash @@ -20,6 +20,7 @@ public typealias EntityComponentHash = Int public typealias ComponentTypeHash = Int // MARK: - hash combine + /// Calculates the combined hash of two values. This implementation is based on boost::hash_combine. /// Will always produce the same result for the same combination of seed and value during the single run of a program. /// @@ -55,27 +56,29 @@ public func hash(combine hashValues: H) -> Int where H.Element: Has } // MARK: - entity component hash + extension EntityComponentHash { - internal static func compose(entityId: EntityIdentifier, componentTypeHash: ComponentTypeHash) -> EntityComponentHash { + static func compose(entityId: EntityIdentifier, componentTypeHash: ComponentTypeHash) -> EntityComponentHash { let entityIdSwapped = UInt(entityId.id).byteSwapped // needs to be 64 bit let componentTypeHashUInt = UInt(bitPattern: componentTypeHash) let hashUInt: UInt = componentTypeHashUInt ^ entityIdSwapped return Int(bitPattern: hashUInt) } - internal static func decompose(_ hash: EntityComponentHash, with entityId: EntityIdentifier) -> ComponentTypeHash { + static func decompose(_ hash: EntityComponentHash, with entityId: EntityIdentifier) -> ComponentTypeHash { let entityIdSwapped = UInt(entityId.id).byteSwapped let entityIdSwappedInt = Int(bitPattern: entityIdSwapped) return hash ^ entityIdSwappedInt } - internal static func decompose(_ hash: EntityComponentHash, with componentTypeHash: ComponentTypeHash) -> EntityIdentifier { + static func decompose(_ hash: EntityComponentHash, with componentTypeHash: ComponentTypeHash) -> EntityIdentifier { let entityId: Int = (hash ^ componentTypeHash).byteSwapped return EntityIdentifier(UInt32(truncatingIfNeeded: entityId)) } } // MARK: - string hashing + /// public enum StringHashing { /// *Waren Singer djb2* @@ -85,7 +88,7 @@ public enum StringHashing { var hash: UInt64 = 5381 var iter = utf8String.unicodeScalars.makeIterator() while let char = iter.next() { - hash = 127 * (hash & 0xFFFFFFFFFFFFFF) &+ UInt64(char.value) + hash = 127 * (hash & 0xFF_FFFF_FFFF_FFFF) &+ UInt64(char.value) } return hash } diff --git a/Sources/FirebladeECS/ManagedContiguousArray.swift b/Sources/FirebladeECS/ManagedContiguousArray.swift index 5d627b1..9f00950 100644 --- a/Sources/FirebladeECS/ManagedContiguousArray.swift +++ b/Sources/FirebladeECS/ManagedContiguousArray.swift @@ -92,6 +92,7 @@ public struct ManagedContiguousArray { } // MARK: - Equatable + extension ManagedContiguousArray: Equatable where Element: Equatable { public static func == (lhs: ManagedContiguousArray, rhs: ManagedContiguousArray) -> Bool { lhs.store == rhs.store @@ -99,4 +100,5 @@ extension ManagedContiguousArray: Equatable where Element: Equatable { } // MARK: - Codable -extension ManagedContiguousArray: Codable where Element: Codable { } + +extension ManagedContiguousArray: Codable where Element: Codable {} diff --git a/Sources/FirebladeECS/Nexus+Component.swift b/Sources/FirebladeECS/Nexus+Component.swift index 33f0819..a707f78 100644 --- a/Sources/FirebladeECS/Nexus+Component.swift +++ b/Sources/FirebladeECS/Nexus+Component.swift @@ -93,7 +93,7 @@ extension Nexus { return false } var iter = allComponents.makeIterator() - var removedAll: Bool = true + var removedAll = true while let component = iter.next() { removedAll = removedAll && remove(component: component, from: entityId) } diff --git a/Sources/FirebladeECS/Nexus+ComponentsBuilder.swift b/Sources/FirebladeECS/Nexus+ComponentsBuilder.swift index ce4b293..d1cd65b 100644 --- a/Sources/FirebladeECS/Nexus+ComponentsBuilder.swift +++ b/Sources/FirebladeECS/Nexus+ComponentsBuilder.swift @@ -6,11 +6,11 @@ // #if swift(<5.4) -@_functionBuilder -public enum ComponentsBuilder { } + @_functionBuilder + public enum ComponentsBuilder {} #else -@resultBuilder -public enum ComponentsBuilder { } + @resultBuilder + public enum ComponentsBuilder {} #endif extension ComponentsBuilder { @@ -39,7 +39,7 @@ extension Nexus { /// - Returns: The newly created entity with the provided component assigned. @discardableResult public func createEntity(@ComponentsBuilder using builder: () -> Component) -> Entity { - self.createEntity(with: builder()) + createEntity(with: builder()) } /// Create an entity assigning multiple components. @@ -55,7 +55,7 @@ extension Nexus { /// - Returns: The newly created entity with the provided components assigned. @discardableResult public func createEntity(@ComponentsBuilder using builder: () -> [Component]) -> Entity { - self.createEntity(with: builder()) + createEntity(with: builder()) } /// Create multiple entities assigning one component each. @@ -72,7 +72,7 @@ extension Nexus { /// - Returns: The newly created entities with the provided component assigned. @discardableResult public func createEntities(count: Int, @ComponentsBuilder using builder: (ComponentsBuilder.Context) -> Component) -> [Entity] { - (0.. [Component] = { _ in [] }) -> [Entity] { - (0..(with components: C) -> Entity where C: Collection, C.Element == Component { - let entity = self.createEntity() + let entity = createEntity() assign(components: components, to: entity.identifier) return entity } @@ -50,7 +50,7 @@ extension Nexus { @discardableResult public func destroy(entity: Entity) -> Bool { - self.destroy(entityId: entity.identifier) + destroy(entityId: entity.identifier) } @discardableResult @@ -76,6 +76,7 @@ extension Nexus { } // MARK: - entities iterator + extension Nexus { public struct EntitiesIterator: IteratorProtocol { private var iterator: AnyIterator @@ -96,5 +97,6 @@ extension Nexus { } } } -extension Nexus.EntitiesIterator: LazySequenceProtocol { } -extension Nexus.EntitiesIterator: Sequence { } + +extension Nexus.EntitiesIterator: LazySequenceProtocol {} +extension Nexus.EntitiesIterator: Sequence {} diff --git a/Sources/FirebladeECS/Nexus+Internal.swift b/Sources/FirebladeECS/Nexus+Internal.swift index 8feafa0..adf0c63 100644 --- a/Sources/FirebladeECS/Nexus+Internal.swift +++ b/Sources/FirebladeECS/Nexus+Internal.swift @@ -104,7 +104,7 @@ extension Nexus { } let isMember: Bool = self.isMember(entity: entityId, inFamilyWithTraits: traits) - if !exists(entity: entityId) && isMember { + if !exists(entity: entityId), isMember { remove(entityWithId: entityId, fromFamilyWithTraits: traits) return } diff --git a/Sources/FirebladeECS/Nexus.swift b/Sources/FirebladeECS/Nexus.swift index 8f7c7f3..554d84a 100644 --- a/Sources/FirebladeECS/Nexus.swift +++ b/Sources/FirebladeECS/Nexus.swift @@ -42,13 +42,14 @@ public final class Nexus { codingStrategy: DefaultCodingStrategy()) } - internal init(componentsByType: [ComponentIdentifier: ManagedContiguousArray], - componentsByEntity: [EntityIdentifier: Set], - entityIdGenerator: EntityIdentifierGenerator, - familyMembersByTraits: [FamilyTraitSet: UnorderedSparseSet], - codingStrategy: CodingStrategy) { + init(componentsByType: [ComponentIdentifier: ManagedContiguousArray], + componentsByEntity: [EntityIdentifier: Set], + entityIdGenerator: EntityIdentifierGenerator, + familyMembersByTraits: [FamilyTraitSet: UnorderedSparseSet], + codingStrategy: CodingStrategy) + { self.componentsByType = componentsByType - self.componentIdsByEntity = componentsByEntity + componentIdsByEntity = componentsByEntity self.familyMembersByTraits = familyMembersByTraits self.entityIdGenerator = entityIdGenerator self.codingStrategy = codingStrategy @@ -66,6 +67,7 @@ public final class Nexus { } // MARK: - CustomDebugStringConvertible + extension Nexus: CustomDebugStringConvertible { public var debugDescription: String { "" @@ -73,8 +75,9 @@ extension Nexus: CustomDebugStringConvertible { } // MARK: - default coding strategy + public struct DefaultCodingStrategy: CodingStrategy { - public init() { } + public init() {} public func codingKey(for componentType: C.Type) -> DynamicCodingKey where C: Component { DynamicCodingKey(stringValue: "\(C.self)").unsafelyUnwrapped diff --git a/Sources/FirebladeECS/NexusEvent.swift b/Sources/FirebladeECS/NexusEvent.swift index 7bc7b38..555effc 100644 --- a/Sources/FirebladeECS/NexusEvent.swift +++ b/Sources/FirebladeECS/NexusEvent.swift @@ -1,5 +1,5 @@ // -// NexusEvents.swift +// NexusEvent.swift // FirebladeECS // // Created by Christian Treffs on 08.10.17. diff --git a/Sources/FirebladeECS/Single.swift b/Sources/FirebladeECS/Single.swift index 36d2c8e..c14b114 100644 --- a/Sources/FirebladeECS/Single.swift +++ b/Sources/FirebladeECS/Single.swift @@ -32,7 +32,7 @@ extension Single where A: SingleComponent { } public var entity: Entity { - Entity(nexus: self.nexus, id: entityId) + Entity(nexus: nexus, id: entityId) } } diff --git a/Sources/FirebladeECS/UnorderedSparseSet.swift b/Sources/FirebladeECS/UnorderedSparseSet.swift index dc6fd79..7999b5a 100644 --- a/Sources/FirebladeECS/UnorderedSparseSet.swift +++ b/Sources/FirebladeECS/UnorderedSparseSet.swift @@ -74,7 +74,7 @@ public struct UnorderedSparseSet { guard let denseIndex = findIndex(at: key) else { return nil } - let entry = self.dense[denseIndex] + let entry = dense[denseIndex] assert(entry.key == key, "entry.key and findIndex(at: key) must be equal!") return entry.element } @@ -99,7 +99,7 @@ public struct UnorderedSparseSet { } let removed = swapRemove(at: denseIndex) - if !dense.isEmpty && denseIndex < dense.count { + if !dense.isEmpty, denseIndex < dense.count { let swappedElement = dense[denseIndex] sparse[swappedElement.key] = denseIndex } @@ -208,12 +208,14 @@ extension UnorderedSparseSet where Key == Int { } // MARK: - Sequence + extension UnorderedSparseSet: Sequence { public func makeIterator() -> ElementIterator { ElementIterator(self) } // MARK: - UnorderedSparseSetIterator + public struct ElementIterator: IteratorProtocol { var iterator: IndexingIterator> @@ -226,17 +228,20 @@ extension UnorderedSparseSet: Sequence { } } } -extension UnorderedSparseSet.ElementIterator: LazySequenceProtocol { } -extension UnorderedSparseSet.ElementIterator: Sequence { } + +extension UnorderedSparseSet.ElementIterator: LazySequenceProtocol {} +extension UnorderedSparseSet.ElementIterator: Sequence {} // MARK: - Equatable -extension UnorderedSparseSet.Storage.Entry: Equatable where Element: Equatable { } + +extension UnorderedSparseSet.Storage.Entry: Equatable where Element: Equatable {} extension UnorderedSparseSet.Storage: Equatable where Element: Equatable { @usableFromInline static func == (lhs: UnorderedSparseSet.Storage, rhs: UnorderedSparseSet.Storage) -> Bool { lhs.dense == rhs.dense && lhs.sparse == rhs.sparse } } + extension UnorderedSparseSet: Equatable where Element: Equatable { public static func == (lhs: UnorderedSparseSet, rhs: UnorderedSparseSet) -> Bool { lhs.storage == rhs.storage @@ -244,6 +249,7 @@ extension UnorderedSparseSet: Equatable where Element: Equatable { } // MARK: - Codable -extension UnorderedSparseSet.Storage.Entry: Codable where Element: Codable { } -extension UnorderedSparseSet.Storage: Codable where Element: Codable { } -extension UnorderedSparseSet: Codable where Element: Codable { } + +extension UnorderedSparseSet.Storage.Entry: Codable where Element: Codable {} +extension UnorderedSparseSet.Storage: Codable where Element: Codable {} +extension UnorderedSparseSet: Codable where Element: Codable {} diff --git a/Tests/FirebladeECSTests/Generated/FamilyTests.generated.swift b/Tests/FirebladeECSTests/Generated/FamilyTests.generated.swift index 3f0b988..345fcf9 100644 --- a/Tests/FirebladeECSTests/Generated/FamilyTests.generated.swift +++ b/Tests/FirebladeECSTests/Generated/FamilyTests.generated.swift @@ -1,6 +1,5 @@ -// Generated using Sourcery 1.0.0 — https://github.com/krzysztofzablocki/Sourcery +// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery // DO NOT EDIT - import FirebladeECS import XCTest From 11f46f354d28031318c38a9d877bce90db30292a Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Wed, 9 Oct 2024 20:52:56 +0200 Subject: [PATCH 24/30] Raise minimum Swift version to 5.8 (#67) * Raise Swift tools version to 5.8 * Update README * Add Swift version file * Format code for 5.8 * Update swiftformat config --- .swift-version | 1 + .swiftformat | 4 +++- Package.swift | 2 +- README.md | 6 +++--- Sources/FirebladeECS/ComponentIdentifier.swift | 4 ++-- Sources/FirebladeECS/Entity.swift | 12 ++++++------ Sources/FirebladeECS/EntityIdentifierGenerator.swift | 2 +- Sources/FirebladeECS/FSM.swift | 6 +++--- Sources/FirebladeECS/Nexus+Component.swift | 4 ++-- Sources/FirebladeECS/Nexus+Entity.swift | 2 +- Sources/FirebladeECS/Nexus+Internal.swift | 4 ++-- Sources/FirebladeECS/Single.swift | 2 +- 12 files changed, 26 insertions(+), 23 deletions(-) create mode 100644 .swift-version diff --git a/.swift-version b/.swift-version new file mode 100644 index 0000000..3659ea2 --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +5.8 diff --git a/.swiftformat b/.swiftformat index 72f3230..884cbf3 100644 --- a/.swiftformat +++ b/.swiftformat @@ -8,4 +8,6 @@ --stripunusedargs closure-only --commas inline --self remove ---selfrequired get \ No newline at end of file +--selfrequired get +--disable preferKeyPath +--disable opaqueGenericParameters \ No newline at end of file diff --git a/Package.swift b/Package.swift index 36f03a2..b547d04 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.1 +// swift-tools-version:5.8 import PackageDescription let package = Package( diff --git a/README.md b/README.md index 081d175..d554942 100644 --- a/README.md +++ b/README.md @@ -25,19 +25,19 @@ These instructions will get you a copy of the project up and running on your loc ### 💻 Installing -Fireblade ECS is available for all platforms that support [Swift 5.1](https://swift.org/) and higher and the [Swift Package Manager (SPM)](https://github.com/apple/swift-package-manager). +Fireblade ECS is available for all platforms that support [Swift 5.8](https://swift.org/) and higher and the [Swift Package Manager (SPM)](https://github.com/apple/swift-package-manager). Extend the following lines in your `Package.swift` file or use it to create a new project. ```swift -// swift-tools-version:5.1 +// swift-tools-version:5.8 import PackageDescription let package = Package( name: "YourPackageName", dependencies: [ - .package(url: "https://github.com/fireblade-engine/ecs.git", from: "0.17.4") + .package(url: "https://github.com/fireblade-engine/ecs.git", from: "0.17.5") ], targets: [ .target( diff --git a/Sources/FirebladeECS/ComponentIdentifier.swift b/Sources/FirebladeECS/ComponentIdentifier.swift index 9a7a5d2..79e6247 100644 --- a/Sources/FirebladeECS/ComponentIdentifier.swift +++ b/Sources/FirebladeECS/ComponentIdentifier.swift @@ -13,12 +13,12 @@ public struct ComponentIdentifier { extension ComponentIdentifier { @usableFromInline - init(_ componentType: C.Type) where C: Component { + init(_ componentType: (some Component).Type) { id = Self.makeRuntimeHash(componentType) } /// object identifier hash (only stable during runtime) - arbitrary hash is ok. - static func makeRuntimeHash(_ componentType: C.Type) -> Identifier where C: Component { + static func makeRuntimeHash(_ componentType: (some Component).Type) -> Identifier { ObjectIdentifier(componentType).hashValue } } diff --git a/Sources/FirebladeECS/Entity.swift b/Sources/FirebladeECS/Entity.swift index 5601834..6ab62cf 100644 --- a/Sources/FirebladeECS/Entity.swift +++ b/Sources/FirebladeECS/Entity.swift @@ -38,13 +38,13 @@ public struct Entity { } @discardableResult - public func createEntity(with components: C) -> Entity where C: Collection, C.Element == Component { + public func createEntity(with components: some Collection) -> Entity { nexus.createEntity(with: components) } /// Checks if a component with given type is assigned to this entity. /// - Parameter type: the component type. - public func has(_ type: C.Type) -> Bool where C: Component { + public func has(_ type: (some Component).Type) -> Bool { has(type.identifier) } @@ -78,13 +78,13 @@ public struct Entity { /// Add a typed component to this entity. /// - Parameter component: the typed component. @discardableResult - public func assign(_ component: C) -> Entity where C: Component { + public func assign(_ component: some Component) -> Entity { assign(component) return self } @discardableResult - public func assign(_ components: C) -> Entity where C: Collection, C.Element == Component { + public func assign(_ components: some Collection) -> Entity { nexus.assign(components: components, to: self) return self } @@ -92,14 +92,14 @@ public struct Entity { /// Remove a component from this entity. /// - Parameter component: the component. @discardableResult - public func remove(_ component: C) -> Entity where C: Component { + public func remove(_ component: some Component) -> Entity { remove(component.identifier) } /// Remove a component by type from this entity. /// - Parameter compType: the component type. @discardableResult - public func remove(_ compType: C.Type) -> Entity where C: Component { + public func remove(_ compType: (some Component).Type) -> Entity { remove(compType.identifier) } diff --git a/Sources/FirebladeECS/EntityIdentifierGenerator.swift b/Sources/FirebladeECS/EntityIdentifierGenerator.swift index 39a12f3..1d6434b 100644 --- a/Sources/FirebladeECS/EntityIdentifierGenerator.swift +++ b/Sources/FirebladeECS/EntityIdentifierGenerator.swift @@ -49,7 +49,7 @@ public struct LinearIncrementingEntityIdGenerator: EntityIdentifierGenerator { @usableFromInline init(startProviding initialEntityIds: EntityIds) where EntityIds: BidirectionalCollection, EntityIds.Element == EntityIdentifier { - let initialInUse: [EntityIdentifier.Identifier] = initialEntityIds.map { $0.id } + let initialInUse: [EntityIdentifier.Identifier] = initialEntityIds.map(\.id) let maxInUseValue = initialInUse.max() ?? 0 let inUseSet = Set(initialInUse) // a set of all eIds in use let allSet = Set(0 ... maxInUseValue) // all eIds from 0 to including maxInUseValue diff --git a/Sources/FirebladeECS/FSM.swift b/Sources/FirebladeECS/FSM.swift index c33790b..4324ada 100644 --- a/Sources/FirebladeECS/FSM.swift +++ b/Sources/FirebladeECS/FSM.swift @@ -251,7 +251,7 @@ extension EntityState { /// - Returns: This EntityState, so more modifications can be applied. @inline(__always) @discardableResult - public func addProvider(type: C.Type, provider: ComponentProvider) -> Self { + public func addProvider(type: (some ComponentInitializable).Type, provider: ComponentProvider) -> Self { addMapping(for: type).withProvider(provider) return self } @@ -316,7 +316,7 @@ public class StateComponentMapping { /// - Parameter closure: The Closure instance to return the component instance /// - Returns: This ComponentMapping, so more modifications can be applied @discardableResult - public func withMethod(_ closure: DynamicComponentProvider.Closure) -> Self { + public func withMethod(_ closure: DynamicComponentProvider.Closure) -> Self { setProvider(DynamicComponentProvider(closure: closure)) return self } @@ -401,7 +401,7 @@ public class EntityStateMachine { var toAdd: [ComponentIdentifier: ComponentProvider] - if let currentState = currentState { + if let currentState { toAdd = .init() for (identifier, provider) in newState.providers { toAdd[identifier] = provider diff --git a/Sources/FirebladeECS/Nexus+Component.swift b/Sources/FirebladeECS/Nexus+Component.swift index a707f78..271f6f0 100644 --- a/Sources/FirebladeECS/Nexus+Component.swift +++ b/Sources/FirebladeECS/Nexus+Component.swift @@ -28,12 +28,12 @@ extension Nexus { } @discardableResult - public final func assign(component: C, to entity: Entity) -> Bool where C: Component { + public final func assign(component: some Component, to entity: Entity) -> Bool { assign(component: component, to: entity) } @discardableResult - public final func assign(components: C, to entity: Entity) -> Bool where C: Collection, C.Element == Component { + public final func assign(components: some Collection, to entity: Entity) -> Bool { assign(components: components, to: entity.identifier) } diff --git a/Sources/FirebladeECS/Nexus+Entity.swift b/Sources/FirebladeECS/Nexus+Entity.swift index 777b3c9..cc0fe7f 100644 --- a/Sources/FirebladeECS/Nexus+Entity.swift +++ b/Sources/FirebladeECS/Nexus+Entity.swift @@ -22,7 +22,7 @@ extension Nexus { } @discardableResult - public func createEntity(with components: C) -> Entity where C: Collection, C.Element == Component { + public func createEntity(with components: some Collection) -> Entity { let entity = createEntity() assign(components: components, to: entity.identifier) return entity diff --git a/Sources/FirebladeECS/Nexus+Internal.swift b/Sources/FirebladeECS/Nexus+Internal.swift index adf0c63..b387303 100644 --- a/Sources/FirebladeECS/Nexus+Internal.swift +++ b/Sources/FirebladeECS/Nexus+Internal.swift @@ -8,7 +8,7 @@ extension Nexus { @usableFromInline @discardableResult - func assign(components: C, to entityId: EntityIdentifier) -> Bool where C: Collection, C.Element == Component { + func assign(components: some Collection, to entityId: EntityIdentifier) -> Bool { var iter = components.makeIterator() while let component = iter.next() { let componentId = component.identifier @@ -103,7 +103,7 @@ extension Nexus { return } - let isMember: Bool = self.isMember(entity: entityId, inFamilyWithTraits: traits) + let isMember: Bool = isMember(entity: entityId, inFamilyWithTraits: traits) if !exists(entity: entityId), isMember { remove(entityWithId: entityId, fromFamilyWithTraits: traits) return diff --git a/Sources/FirebladeECS/Single.swift b/Sources/FirebladeECS/Single.swift index c14b114..2d64936 100644 --- a/Sources/FirebladeECS/Single.swift +++ b/Sources/FirebladeECS/Single.swift @@ -38,7 +38,7 @@ extension Single where A: SingleComponent { extension Nexus { public func single(_ component: S.Type) -> Single where S: SingleComponent { - let family = self.family(requires: S.self) + let family = family(requires: S.self) precondition(family.count <= 1, "Singleton count of \(S.self) must be 0 or 1: \(family.count)") let entityId: EntityIdentifier if family.isEmpty { From 3ce36faf2db025d6f3dc605e3f1110c805178a1f Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Thu, 10 Oct 2024 10:56:56 +0200 Subject: [PATCH 25/30] Add support for fork PR workflows (#71) * Conditionally run code coverage * Update ci-macos.yml --- .github/workflows/ci-macos.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index e42882c..c6657fb 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -5,6 +5,11 @@ on: branches: [ master ] pull_request: branches: [ master ] + workflow_dispatch: + +env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + CODECOV_XCODE_VERSION: "15.4" # Xcode version used to generate code coverage jobs: macos-test-build-release-xcode: @@ -12,15 +17,19 @@ jobs: strategy: matrix: xcode: ["14.3.1", "15.4", "16.0"] + steps: - name: Checkout uses: actions/checkout@v4 + - name: Select Xcode ${{ matrix.xcode }} run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app + - name: Test run: swift test -c release --parallel --xunit-output .build/xUnit-output.xml --enable-code-coverage env: DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer + - name: Upload test artifacts if: failure() uses: actions/upload-artifact@v4.4.2 @@ -37,11 +46,15 @@ jobs: if-no-files-found: warn include-hidden-files: true + # Only run coverage steps if the CODECOV_TOKEN is available and the matrix.xcode matches CODECOV_XCODE_VERSION - name: Generate coverage report + if: env.CODECOV_TOKEN != '' && matrix.xcode == env.CODECOV_XCODE_VERSION run: xcrun llvm-cov export -format="lcov" .build/**/*PackageTests.xctest/Contents/MacOS/*PackageTests -instr-profile .build/**/codecov/default.profdata > coverage.lcov + - name: Upload code coverage report + if: env.CODECOV_TOKEN != '' && matrix.xcode == env.CODECOV_XCODE_VERSION uses: codecov/codecov-action@v4.6.0 with: - token: ${{ secrets.CODECOV_TOKEN }} + token: ${{ env.CODECOV_TOKEN }} file: coverage.lcov fail_ci_if_error: true From 85ed3e2862cb0877a76746df674a3d2ca5000b57 Mon Sep 17 00:00:00 2001 From: Joseph Heck Date: Thu, 10 Oct 2024 02:08:53 -0700 Subject: [PATCH 26/30] marks sourcery stencils as excluded from swiftpm processing (#69) Co-authored-by: Christian Treffs --- Package.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index b547d04..424738d 100644 --- a/Package.swift +++ b/Package.swift @@ -8,9 +8,11 @@ let package = Package( targets: ["FirebladeECS"]) ], targets: [ - .target(name: "FirebladeECS"), + .target(name: "FirebladeECS", + exclude: ["Stencils/Family.stencil"]), .testTarget(name: "FirebladeECSTests", - dependencies: ["FirebladeECS"]), + dependencies: ["FirebladeECS"], + exclude: ["Stencils/FamilyTests.stencil"]), .testTarget(name: "FirebladeECSPerformanceTests", dependencies: ["FirebladeECS"]) ], From 0b3ba9241be23e4787ae9421728faab9bd9ba9e6 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 10 Oct 2024 11:13:26 +0200 Subject: [PATCH 27/30] Update actions/upload-artifact action to v4.4.3 (#68) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci-linux.yml | 2 +- .github/workflows/ci-macos.yml | 2 +- .github/workflows/ci-windows.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 6e5dd19..38fad3a 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -23,7 +23,7 @@ jobs: - name: Upload test artifacts if: failure() - uses: actions/upload-artifact@v4.4.2 + uses: actions/upload-artifact@v4.4.3 with: name: test-artifacts-linux-${{ matrix.swift }}-${{ github.run_id }} path: | diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index c6657fb..58641bb 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -32,7 +32,7 @@ jobs: - name: Upload test artifacts if: failure() - uses: actions/upload-artifact@v4.4.2 + uses: actions/upload-artifact@v4.4.3 with: name: test-artifacts-${{ matrix.xcode }}-${{ github.run_id }} path: | diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index 7614153..ab95135 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -24,7 +24,7 @@ jobs: - name: Upload test artifacts if: failure() - uses: actions/upload-artifact@v4.4.2 + uses: actions/upload-artifact@v4.4.3 with: name: test-artifacts-windows-${{ github.run_id }} path: | From e0ee97bd7f401a83cf7d13b938d0161ec2ba511d Mon Sep 17 00:00:00 2001 From: Joseph Heck Date: Thu, 10 Oct 2024 09:51:46 -0700 Subject: [PATCH 28/30] adding package-benchmark sub-project (#64) --- .codecov.yml | 3 +- Benchmarks/Benchmarks/ECSBenchmark/Base.swift | 85 ++++++++ .../ECSBenchmark/OneDimensionBenchmarks.swift | 198 ++++++++++++++++++ Benchmarks/Package.swift | 28 +++ Benchmarks/README.md | 22 ++ 5 files changed, 335 insertions(+), 1 deletion(-) create mode 100644 Benchmarks/Benchmarks/ECSBenchmark/Base.swift create mode 100644 Benchmarks/Benchmarks/ECSBenchmark/OneDimensionBenchmarks.swift create mode 100644 Benchmarks/Package.swift create mode 100644 Benchmarks/README.md diff --git a/.codecov.yml b/.codecov.yml index 4d717c6..1db9c06 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1,5 +1,6 @@ ignore: - "Tests/" + - "Benchmarks/" comment: - layout: header, changes, diff \ No newline at end of file + layout: header, changes, diff diff --git a/Benchmarks/Benchmarks/ECSBenchmark/Base.swift b/Benchmarks/Benchmarks/ECSBenchmark/Base.swift new file mode 100644 index 0000000..fe0da9d --- /dev/null +++ b/Benchmarks/Benchmarks/ECSBenchmark/Base.swift @@ -0,0 +1,85 @@ +// +// Base.swift +// FirebladeECSTests +// +// Created by Christian Treffs on 09.10.17. +// + +import FirebladeECS + +class EmptyComponent: Component {} + +class Name: Component { + var name: String + init(name: String) { + self.name = name + } +} + +class Position: Component { + var x: Int + var y: Int + init(x: Int, y: Int) { + self.x = x + self.y = y + } +} + +class Velocity: Component { + var a: Float + init(a: Float) { + self.a = a + } +} + +class Party: Component { + var partying: Bool + init(partying: Bool) { + self.partying = partying + } +} + +class Color: Component { + var r: UInt8 = 0 + var g: UInt8 = 0 + var b: UInt8 = 0 +} + +class ExampleSystem { + private let family: Family2 + + init(nexus: Nexus) { + family = nexus.family(requiresAll: Position.self, Velocity.self, excludesAll: EmptyComponent.self) + } + + func update(deltaT _: Double) { + for (position, velocity) in family { + position.x *= 2 + velocity.a *= 2 + } + } +} + +final class SingleGameState: SingleComponent { + var shouldQuit: Bool = false + var playerHealth: Int = 67 +} + +func setUpNexus() -> Nexus { + let numEntities = 10000 + let nexus = Nexus() + + for i in 0 ..< numEntities { + nexus.createEntity().assign(Position(x: 1 + i, y: 2 + i), + Name(name: "myName\(i)"), + Velocity(a: 3.14), + EmptyComponent(), + Color()) + } + + precondition(nexus.numEntities == numEntities) +// precondition(nexus.numFamilies == 1) + precondition(nexus.numComponents == numEntities * 5) + + return nexus +} diff --git a/Benchmarks/Benchmarks/ECSBenchmark/OneDimensionBenchmarks.swift b/Benchmarks/Benchmarks/ECSBenchmark/OneDimensionBenchmarks.swift new file mode 100644 index 0000000..bceee0d --- /dev/null +++ b/Benchmarks/Benchmarks/ECSBenchmark/OneDimensionBenchmarks.swift @@ -0,0 +1,198 @@ +// swiftformat:disable preferForLoop +import Benchmark +import FirebladeECS + +// derived from FirebladeECSPerformanceTests/TypedFamilyPerformanceTests.swift in the parent project + +let benchmarks = { + Benchmark("TraitMatching") { benchmark in + let nexus = setUpNexus() + let a = nexus.createEntity() + a.assign(Position(x: 1, y: 2)) + a.assign(Name(name: "myName")) + a.assign(Velocity(a: 3.14)) + a.assign(EmptyComponent()) + + let isMatch = nexus.family(requiresAll: Position.self, Velocity.self, + excludesAll: Party.self) + + for _ in benchmark.scaledIterations { + blackHole( + isMatch.canBecomeMember(a) + ) + } + } + + Benchmark("TypedFamilyEntities") { benchmark in + let nexus = setUpNexus() + let family = nexus.family(requires: Position.self, excludesAll: Party.self) + for _ in benchmark.scaledIterations { + blackHole( + family + .entities + .forEach { (entity: Entity) in + _ = entity + } + ) + } + } + + Benchmark("TypedFamilyOneComponent") { benchmark in + let nexus = setUpNexus() + let family = nexus.family(requires: Position.self, excludesAll: Party.self) + for _ in benchmark.scaledIterations { + blackHole( + family + .forEach { (position: Position) in + _ = position + } + ) + } + } + + Benchmark("TypedFamilyEntityOneComponent") { benchmark in + let nexus = setUpNexus() + let family = nexus.family(requires: Position.self, excludesAll: Party.self) + for _ in benchmark.scaledIterations { + blackHole( + family + .entityAndComponents + .forEach { (entity: Entity, position: Position) in + _ = entity + _ = position + } + ) + } + } + + Benchmark("TypedFamilyTwoComponents") { benchmark in + let nexus = setUpNexus() + let family = nexus.family(requiresAll: Position.self, Velocity.self, excludesAll: Party.self) + for _ in benchmark.scaledIterations { + blackHole( + family + .forEach { (position: Position, velocity: Velocity) in + _ = position + _ = velocity + } + ) + } + } + Benchmark("TypedFamilyEntityTwoComponents") { benchmark in + let nexus = setUpNexus() + let family = nexus.family(requiresAll: Position.self, Velocity.self, excludesAll: Party.self) + for _ in benchmark.scaledIterations { + blackHole( + family + .entityAndComponents + .forEach { (entity: Entity, position: Position, velocity: Velocity) in + _ = entity + _ = position + _ = velocity + } + ) + } + } + + Benchmark("TypedFamilyThreeComponents") { benchmark in + let nexus = setUpNexus() + let family = nexus.family(requiresAll: Position.self, Velocity.self, Name.self, excludesAll: Party.self) + for _ in benchmark.scaledIterations { + blackHole( + family + .forEach { (position: Position, velocity: Velocity, name: Name) in + _ = position + _ = velocity + _ = name + } + ) + } + } + Benchmark("TypedFamilyEntityThreeComponents") { benchmark in + let nexus = setUpNexus() + let family = nexus.family(requiresAll: Position.self, Velocity.self, Name.self, excludesAll: Party.self) + for _ in benchmark.scaledIterations { + blackHole( + family + .entityAndComponents + .forEach { (entity: Entity, position: Position, velocity: Velocity, name: Name) in + _ = entity + _ = position + _ = velocity + _ = name + } + ) + } + } + + Benchmark("TypedFamilyFourComponents") { benchmark in + let nexus = setUpNexus() + let family = nexus.family(requiresAll: Position.self, Velocity.self, Name.self, Color.self, excludesAll: Party.self) + for _ in benchmark.scaledIterations { + blackHole( + family + .forEach { (position: Position, velocity: Velocity, name: Name, color: Color) in + _ = position + _ = velocity + _ = name + _ = color + } + ) + } + } + + Benchmark("TypedFamilyEntityFourComponents") { benchmark in + let nexus = setUpNexus() + let family = nexus.family(requiresAll: Position.self, Velocity.self, Name.self, Color.self, excludesAll: Party.self) + for _ in benchmark.scaledIterations { + blackHole( + family + .entityAndComponents + .forEach { (entity: Entity, position: Position, velocity: Velocity, name: Name, color: Color) in + _ = entity + _ = position + _ = velocity + _ = name + _ = color + } + ) + } + } + + Benchmark("TypedFamilyFiveComponents") { benchmark in + let nexus = setUpNexus() + let family = nexus.family(requiresAll: Position.self, Velocity.self, Name.self, Color.self, EmptyComponent.self, excludesAll: Party.self) + + for _ in benchmark.scaledIterations { + blackHole( + family + .forEach { (position: Position, velocity: Velocity, name: Name, color: Color, empty: EmptyComponent) in + _ = position + _ = velocity + _ = name + _ = color + _ = empty + } + ) + } + } + + Benchmark("TypedFamilyEntityFiveComponents") { benchmark in + let nexus = setUpNexus() + let family = nexus.family(requiresAll: Position.self, Velocity.self, Name.self, Color.self, EmptyComponent.self, excludesAll: Party.self) + + for _ in benchmark.scaledIterations { + blackHole(family + .entityAndComponents + .forEach { (entity: Entity, position: Position, velocity: Velocity, name: Name, color: Color, empty: EmptyComponent) in + _ = entity + _ = position + _ = velocity + _ = name + _ = color + _ = empty + } + ) + } + } +} diff --git a/Benchmarks/Package.swift b/Benchmarks/Package.swift new file mode 100644 index 0000000..62656d1 --- /dev/null +++ b/Benchmarks/Package.swift @@ -0,0 +1,28 @@ +// swift-tools-version: 5.8 + +import PackageDescription + +let package = Package( + name: "ECSBenchmarks", + platforms: [ + .iOS(.v16), + .macOS(.v13) + ], + dependencies: [ + .package(path: "../"), + .package(url: "https://github.com/ordo-one/package-benchmark", .upToNextMajor(from: "1.4.0")) + ], + targets: [ + .executableTarget( + name: "ECSBenchmark", + dependencies: [ + .product(name: "FirebladeECS", package: "ecs"), + .product(name: "Benchmark", package: "package-benchmark") + ], + path: "Benchmarks/ECSBenchmark", + plugins: [ + .plugin(name: "BenchmarkPlugin", package: "package-benchmark") + ] + ) + ] +) diff --git a/Benchmarks/README.md b/Benchmarks/README.md new file mode 100644 index 0000000..0d525f6 --- /dev/null +++ b/Benchmarks/README.md @@ -0,0 +1,22 @@ +# Benchmarks for FirebladeECS + +Originally seeded by replicating performance tests into a new form leveraging [package-benchmark](https://swiftpackageindex.com/ordo-one/package-benchmark/) [Documentation](https://swiftpackageindex.com/ordo-one/package-benchmark/main/documentation/benchmark). + +To run all the available benchmarks: + + swift package benchmark --format markdown + +For more help on the package-benchmark SwiftPM plugin: + + swift package benchmark help + +Creating a local baseline: + + swift package --allow-writing-to-package-directory benchmark baseline update dev + swift package benchmark baseline list + +Comparing to a the baseline 'alpha' + + swift package benchmark baseline compare dev + +For more details on creating and comparing baselines, read [Creating and Comparing Benchmark Baselines](https://swiftpackageindex.com/ordo-one/package-benchmark/main/documentation/benchmark/creatingandcomparingbaselines). From d4e779fc669cd5c71a89fdb722f06721d0b8a53f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 13 Oct 2024 12:04:47 +0200 Subject: [PATCH 29/30] Update dependency ordo-one/package-benchmark to from: "1.27.2" (#73) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Benchmarks/Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Benchmarks/Package.swift b/Benchmarks/Package.swift index 62656d1..67dbadf 100644 --- a/Benchmarks/Package.swift +++ b/Benchmarks/Package.swift @@ -10,7 +10,7 @@ let package = Package( ], dependencies: [ .package(path: "../"), - .package(url: "https://github.com/ordo-one/package-benchmark", .upToNextMajor(from: "1.4.0")) + .package(url: "https://github.com/ordo-one/package-benchmark", .upToNextMajor(from: "1.27.2")) ], targets: [ .executableTarget( From 9708eba6cb0e91326dfb402764cf37aa658cbb4c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 07:17:18 +0200 Subject: [PATCH 30/30] Update dependency ordo-one/package-benchmark to from: "1.27.3" (#75) --- Benchmarks/Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Benchmarks/Package.swift b/Benchmarks/Package.swift index 67dbadf..8be6cba 100644 --- a/Benchmarks/Package.swift +++ b/Benchmarks/Package.swift @@ -10,7 +10,7 @@ let package = Package( ], dependencies: [ .package(path: "../"), - .package(url: "https://github.com/ordo-one/package-benchmark", .upToNextMajor(from: "1.27.2")) + .package(url: "https://github.com/ordo-one/package-benchmark", .upToNextMajor(from: "1.27.3")) ], targets: [ .executableTarget(