diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..08891d8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true \ No newline at end of file diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..f96b514 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,14 @@ +changelog: + categories: + - title: SemVer Major + labels: + - ⚠️ semver/major + - title: SemVer Minor + labels: + - semver/minor + - title: SemVer Patch + labels: + - semver/patch + - title: Other Changes + labels: + - semver/none diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..400a1b9 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,18 @@ +name: Main + +on: + push: + branches: [main] + schedule: + - cron: "0 8,20 * * *" + +jobs: + unit-tests: + name: Unit tests + uses: apple/swift-nio/.github/workflows/unit_tests.yml@main + with: + linux_5_9_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error" + linux_5_10_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error" + linux_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" + linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" + linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 0000000..d90d2a4 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,26 @@ +name: PR + +on: + pull_request: + types: [opened, reopened, synchronize] + +jobs: + soundness: + name: Soundness + uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main + with: + license_header_check_project_name: "SwiftPrometheus" + + unit-tests: + name: Unit tests + uses: apple/swift-nio/.github/workflows/unit_tests.yml@main + with: + linux_5_9_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error" + linux_5_10_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error" + linux_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" + linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" + linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" + + cxx-interop: + name: Cxx interop + uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main diff --git a/.github/workflows/pull_request_label.yml b/.github/workflows/pull_request_label.yml new file mode 100644 index 0000000..8fd47c1 --- /dev/null +++ b/.github/workflows/pull_request_label.yml @@ -0,0 +1,18 @@ +name: PR label + +on: + pull_request: + types: [labeled, unlabeled, opened, reopened, synchronize] + +jobs: + semver-label-check: + name: Semantic version label check + runs-on: ubuntu-latest + timeout-minutes: 1 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Check for Semantic Version label + uses: apple/swift-nio/.github/actions/pull_request_semver_label_checker@main diff --git a/.licenseignore b/.licenseignore new file mode 100644 index 0000000..d2535f5 --- /dev/null +++ b/.licenseignore @@ -0,0 +1,36 @@ +.gitignore +**/.gitignore +.licenseignore +.gitattributes +.git-blame-ignore-revs +.mailfilter +.mailmap +.spi.yml +.swift-format +.swiftformatignore +.editorconfig +.github/* +*.md +*.txt +*.yml +*.yaml +*.json +Package.swift +**/Package.swift +Package@-*.swift +**/Package@-*.swift +Package.resolved +**/Package.resolved +Makefile +*.modulemap +**/*.modulemap +**/*.docc/* +*.xcprivacy +**/*.xcprivacy +*.symlink +**/*.symlink +Dockerfile +**/Dockerfile +Snippets/* +dev/git.commit.template +.unacceptablelanguageignore diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..5fbeead --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,65 @@ +## Legal + +By submitting a pull request, you represent that you have the right to license +your contribution to Apple and the community, and agree by submitting the patch +that your contributions are licensed under the Apache 2.0 license (see +`LICENSE.txt`). + +## How to submit a bug report + +Please ensure to specify the following: + +* swift-prometheus commit hash +* Contextual information (e.g. what you were trying to achieve with swift-prometheus) +* Simplest possible steps to reproduce + * More complex the steps are, lower the priority will be. + * A pull request with failing test case is preferred, but it's just fine to paste the test case into the issue description. +* Anything that might be relevant in your opinion, such as: + * Swift version or the output of `swift --version` + * OS version and the output of `uname -a` + * Network configuration + + +### Example + +``` +swift-prometheus commit hash: 22ec043dc9d24bb011b47ece4f9ee97ee5be2757 + +Context: +While load testing my program written with swift-prometheus, I noticed +that one file descriptor is leaked per request. + +Steps to reproduce: +1. ... +2. ... +3. ... +4. ... + +$ swift --version +Swift version 4.0.2 (swift-4.0.2-RELEASE) +Target: x86_64-unknown-linux-gnu + +Operating system: Ubuntu Linux 16.04 64-bit + +$ uname -a +Linux beefy.machine 4.4.0-101-generic #124-Ubuntu SMP Fri Nov 10 18:29:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux + +My system has IPv6 disabled. +``` + +## Writing a Patch + +A good swift-prometheus patch is: + +1. Concise, and contains as few changes as needed to achieve the end result. +2. Tested, ensuring that any tests provided failed before the patch and pass after it. +3. Documented, adding API documentation as needed to cover new functions and properties. +4. Accompanied by a great commit message, using our commit message template. + +### Run CI checks locally + +You can run the GitHub Actions workflows locally using [act](https://github.com/nektos/act). For detailed steps on how to do this please see [https://github.com/swiftlang/github-workflows?tab=readme-ov-file#running-workflows-locally](https://github.com/swiftlang/github-workflows?tab=readme-ov-file#running-workflows-locally). + +## How to contribute your work + +Please open a pull request at https://github.com/swift-server/swift-prometheus. Make sure the CI passes, and then wait for code review. diff --git a/LICENSE b/LICENSE.txt similarity index 100% rename from LICENSE rename to LICENSE.txt diff --git a/Package.swift b/Package.swift index ed52f8a..9317585 100644 --- a/Package.swift +++ b/Package.swift @@ -3,7 +3,7 @@ // // This source file is part of the SwiftPrometheus open source project // -// Copyright (c) 2018-2023 SwiftPrometheus project authors +// Copyright (c) 2018-$§ Apple Inc. and the SwiftPrometheus project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information @@ -22,14 +22,11 @@ let package = Package( .library( name: "Prometheus", targets: ["Prometheus"] - ), + ) ], dependencies: [ .package(url: "https://github.com/apple/swift-atomics.git", from: "1.0.2"), .package(url: "https://github.com/apple/swift-metrics.git", from: "2.4.1"), - - // ~~~ SwiftPM Plugins ~~~ - .package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.3.0"), ], targets: [ .target( @@ -42,7 +39,7 @@ let package = Package( .testTarget( name: "PrometheusTests", dependencies: [ - "Prometheus", + "Prometheus" ] ), ] diff --git a/Sources/Prometheus/Counter.swift b/Sources/Prometheus/Counter.swift index 6a90a6f..62e5070 100644 --- a/Sources/Prometheus/Counter.swift +++ b/Sources/Prometheus/Counter.swift @@ -2,7 +2,7 @@ // // This source file is part of the SwiftPrometheus open source project // -// Copyright (c) 2018-2023 SwiftPrometheus project authors +// Copyright (c) 2018-2023 Apple Inc. and the SwiftPrometheus project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information diff --git a/Sources/Prometheus/Docs.docc/swift-metrics.md b/Sources/Prometheus/Docs.docc/swift-metrics.md index e5d6572..460429f 100644 --- a/Sources/Prometheus/Docs.docc/swift-metrics.md +++ b/Sources/Prometheus/Docs.docc/swift-metrics.md @@ -111,8 +111,8 @@ generated in a third party library. #### Default buckets -Swift Metric ``Timer``s are backed by a Prometheus ``DurationHistogram`` and Swift Metric -``Recorder``s that aggregate are backed by a Prometheus ``ValueHistogram``. As a user, you can +Swift Metric `Timer`s are backed by a Prometheus ``DurationHistogram`` and Swift Metric +`Recorder`s that aggregate are backed by a Prometheus ``ValueHistogram``. As a user, you can specify which buckets shall be used within the backing ``Histogram``s. ```swift diff --git a/Sources/Prometheus/Gauge.swift b/Sources/Prometheus/Gauge.swift index c74b57c..afac963 100644 --- a/Sources/Prometheus/Gauge.swift +++ b/Sources/Prometheus/Gauge.swift @@ -2,7 +2,7 @@ // // This source file is part of the SwiftPrometheus open source project // -// Copyright (c) 2018-2023 SwiftPrometheus project authors +// Copyright (c) 2018-2023 Apple Inc. and the SwiftPrometheus project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information diff --git a/Sources/Prometheus/Histogram.swift b/Sources/Prometheus/Histogram.swift index dabe2a0..efab461 100644 --- a/Sources/Prometheus/Histogram.swift +++ b/Sources/Prometheus/Histogram.swift @@ -2,7 +2,7 @@ // // This source file is part of the SwiftPrometheus open source project // -// Copyright (c) 2018-2023 SwiftPrometheus project authors +// Copyright (c) 2018-2023 Apple Inc. and the SwiftPrometheus project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information diff --git a/Sources/Prometheus/NIOLock.swift b/Sources/Prometheus/NIOLock.swift index 3a80b6c..5242401 100644 --- a/Sources/Prometheus/NIOLock.swift +++ b/Sources/Prometheus/NIOLock.swift @@ -2,7 +2,7 @@ // // This source file is part of the SwiftPrometheus open source project // -// Copyright (c) 2023 SwiftPrometheus project authors +// Copyright (c) 2023 Apple Inc. and the SwiftPrometheus project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information diff --git a/Sources/Prometheus/NIOLockedValueBox.swift b/Sources/Prometheus/NIOLockedValueBox.swift index 9dcef47..a31d13a 100644 --- a/Sources/Prometheus/NIOLockedValueBox.swift +++ b/Sources/Prometheus/NIOLockedValueBox.swift @@ -2,7 +2,7 @@ // // This source file is part of the SwiftPrometheus open source project // -// Copyright (c) 2023 SwiftPrometheus project authors +// Copyright (c) 2023 Apple Inc. and the SwiftPrometheus project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information diff --git a/Sources/Prometheus/PrometheusCollectorRegistry.swift b/Sources/Prometheus/PrometheusCollectorRegistry.swift index 4975ab2..b6b8255 100644 --- a/Sources/Prometheus/PrometheusCollectorRegistry.swift +++ b/Sources/Prometheus/PrometheusCollectorRegistry.swift @@ -2,7 +2,7 @@ // // This source file is part of the SwiftPrometheus open source project // -// Copyright (c) 2018-2023 SwiftPrometheus project authors +// Copyright (c) 2018-2023 Apple Inc. and the SwiftPrometheus project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information diff --git a/Sources/Prometheus/PrometheusMetricsFactory.swift b/Sources/Prometheus/PrometheusMetricsFactory.swift index 7511cf3..85fdbaa 100644 --- a/Sources/Prometheus/PrometheusMetricsFactory.swift +++ b/Sources/Prometheus/PrometheusMetricsFactory.swift @@ -2,7 +2,7 @@ // // This source file is part of the SwiftPrometheus open source project // -// Copyright (c) 2018-2023 SwiftPrometheus project authors +// Copyright (c) 2018-2023 Apple Inc. and the SwiftPrometheus project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information @@ -19,7 +19,7 @@ public struct PrometheusMetricsFactory: Sendable { private static let _defaultRegistry = PrometheusCollectorRegistry() /// The default ``PrometheusCollectorRegistry``, which is used inside the ``PrometheusMetricsFactory`` - /// if no other is provided in ``init(client:)`` or set via ``PrometheusMetricsFactory/client`` + /// if no other is provided in ``init(registry:)`` or set via ``PrometheusMetricsFactory/registry`` public static var defaultRegistry: PrometheusCollectorRegistry { self._defaultRegistry } @@ -27,12 +27,12 @@ public struct PrometheusMetricsFactory: Sendable { /// The underlying ``PrometheusCollectorRegistry`` that is used to generate the swift-metrics handlers public var registry: PrometheusCollectorRegistry - /// The default histogram buckets for a ``TimeHistogram``. If there is no explicit overwrite + /// The default histogram buckets for a ``DurationHistogram``. If there is no explicit overwrite /// via ``durationHistogramBuckets``, the buckets provided here will be used for any new /// Swift Metrics `Timer` type. public var defaultDurationHistogramBuckets: [Duration] - /// The histogram buckets for a ``TimeHistogram`` per Timer label + /// The histogram buckets for a ``DurationHistogram`` per Timer label public var durationHistogramBuckets: [String: [Duration]] /// The default histogram buckets for a ``ValueHistogram``. If there is no explicit overwrite diff --git a/Tests/PrometheusTests/CounterTests.swift b/Tests/PrometheusTests/CounterTests.swift index ab78914..7b18425 100644 --- a/Tests/PrometheusTests/CounterTests.swift +++ b/Tests/PrometheusTests/CounterTests.swift @@ -2,7 +2,7 @@ // // This source file is part of the SwiftPrometheus open source project // -// Copyright (c) 2018-2023 SwiftPrometheus project authors +// Copyright (c) 2018-2023 Apple Inc. and the SwiftPrometheus project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information diff --git a/Tests/PrometheusTests/GaugeTests.swift b/Tests/PrometheusTests/GaugeTests.swift index aef6d0d..452ee9c 100644 --- a/Tests/PrometheusTests/GaugeTests.swift +++ b/Tests/PrometheusTests/GaugeTests.swift @@ -2,7 +2,7 @@ // // This source file is part of the SwiftPrometheus open source project // -// Copyright (c) 2018-2023 SwiftPrometheus project authors +// Copyright (c) 2018-2023 Apple Inc. and the SwiftPrometheus project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information diff --git a/Tests/PrometheusTests/HistogramTests.swift b/Tests/PrometheusTests/HistogramTests.swift index 8c5705a..6694156 100644 --- a/Tests/PrometheusTests/HistogramTests.swift +++ b/Tests/PrometheusTests/HistogramTests.swift @@ -2,7 +2,7 @@ // // This source file is part of the SwiftPrometheus open source project // -// Copyright (c) 2018-2023 SwiftPrometheus project authors +// Copyright (c) 2018-2023 Apple Inc. and the SwiftPrometheus project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information diff --git a/Tests/PrometheusTests/PrometheusCollectorRegistryTests.swift b/Tests/PrometheusTests/PrometheusCollectorRegistryTests.swift index c883f81..7e595fc 100644 --- a/Tests/PrometheusTests/PrometheusCollectorRegistryTests.swift +++ b/Tests/PrometheusTests/PrometheusCollectorRegistryTests.swift @@ -2,7 +2,7 @@ // // This source file is part of the SwiftPrometheus open source project // -// Copyright (c) 2018-2023 SwiftPrometheus project authors +// Copyright (c) 2018-2023 Apple Inc. and the SwiftPrometheus project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information diff --git a/Tests/PrometheusTests/PrometheusMetricsFactoryTests.swift b/Tests/PrometheusTests/PrometheusMetricsFactoryTests.swift index 0966676..61a6495 100644 --- a/Tests/PrometheusTests/PrometheusMetricsFactoryTests.swift +++ b/Tests/PrometheusTests/PrometheusMetricsFactoryTests.swift @@ -2,7 +2,7 @@ // // This source file is part of the SwiftPrometheus open source project // -// Copyright (c) 2018-2023 SwiftPrometheus project authors +// Copyright (c) 2018-2023 Apple Inc. and the SwiftPrometheus project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information diff --git a/Tests/PrometheusTests/ValidNamesTests.swift b/Tests/PrometheusTests/ValidNamesTests.swift index ca099e5..16ba9a0 100644 --- a/Tests/PrometheusTests/ValidNamesTests.swift +++ b/Tests/PrometheusTests/ValidNamesTests.swift @@ -2,7 +2,7 @@ // // This source file is part of the SwiftPrometheus open source project // -// Copyright (c) 2024 SwiftPrometheus project authors +// Copyright (c) 2024 Apple Inc. and the SwiftPrometheus project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index b2d7e83..0000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -ARG swift_version=5.8 -ARG ubuntu_version=jammy -ARG base_image=swift:$swift_version-$ubuntu_version -FROM $base_image -# needed to do again after FROM due to docker limitation -ARG swift_version -ARG ubuntu_version - -# set as UTF-8 -RUN apt-get update && apt-get install -y locales locales-all -ENV LC_ALL en_US.UTF-8 -ENV LANG en_US.UTF-8 -ENV LANGUAGE en_US.UTF-8 - -# dependencies -RUN apt-get update && apt-get install -y wget -RUN apt-get update && apt-get install -y lsof dnsutils netcat-openbsd net-tools libz-dev curl jq # used by integration tests - -# ruby and jazzy for docs generation -RUN apt-get update && apt-get install -y ruby ruby-dev libsqlite3-dev build-essential -# jazzy no longer works on xenial as ruby is too old. -RUN if [ "${ubuntu_version}" = "focal" ] ; then echo "gem: --no-document" > ~/.gemrc; fi -RUN if [ "${ubuntu_version}" = "focal" ] ; then gem install jazzy; fi - -# tools -RUN mkdir -p $HOME/.tools -RUN echo 'export PATH="$HOME/.tools:$PATH"' >> $HOME/.profile - -# swift-format (until part of the toolchain) -RUN mkdir -p $HOME/.deps -RUN git clone --branch release/$swift_version --depth 1 https://github.com/apple/swift-format $HOME/.deps/swift-format -RUN cd $HOME/.deps/swift-format && swift build -c release -RUN ln -s $HOME/.deps/swift-format/.build/release/swift-format $HOME/.tools diff --git a/docker/docker-compose.2204.57.yaml b/docker/docker-compose.2204.57.yaml deleted file mode 100644 index fa96acd..0000000 --- a/docker/docker-compose.2204.57.yaml +++ /dev/null @@ -1,21 +0,0 @@ -version: "3" - -services: - - runtime-setup: - image: prometheus:22.04-5.7 - build: - args: - ubuntu_version: "jammy" - swift_version: "5.7" - - documentation-check: - image: prometheus:22.04-5.7 - - test: - image: prometheus:22.04-5.7 - environment: [] - #- SANITIZER_ARG=--sanitize=thread - - shell: - image: prometheus:22.04-5.7 diff --git a/docker/docker-compose.2204.58.yaml b/docker/docker-compose.2204.58.yaml deleted file mode 100644 index 1d27d8e..0000000 --- a/docker/docker-compose.2204.58.yaml +++ /dev/null @@ -1,22 +0,0 @@ -version: "3" - -services: - - runtime-setup: - image: prometheus:22.04-5.8 - build: - args: - ubuntu_version: "jammy" - swift_version: "5.8" - - documentation-check: - image: prometheus:22.04-5.8 - - test: - image: prometheus:22.04-5.8 - environment: - - IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error - #- SANITIZER_ARG=--sanitize=thread - - shell: - image: prometheus:22.04-5.8 diff --git a/docker/docker-compose.2204.59.yaml b/docker/docker-compose.2204.59.yaml deleted file mode 100644 index 90a0799..0000000 --- a/docker/docker-compose.2204.59.yaml +++ /dev/null @@ -1,22 +0,0 @@ -version: "3" - -services: - - runtime-setup: - image: prometheus:22.04-5.9 - build: - args: - ubuntu_version: "jammy" - swift_version: "5.9" - - documentation-check: - image: prometheus:22.04-5.9 - - test: - image: prometheus:22.04-5.9 - environment: - - IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error - #- SANITIZER_ARG=--sanitize=thread - - shell: - image: prometheus:22.04-5.9 diff --git a/docker/docker-compose.2204.main.yaml b/docker/docker-compose.2204.main.yaml deleted file mode 100644 index 461eefc..0000000 --- a/docker/docker-compose.2204.main.yaml +++ /dev/null @@ -1,21 +0,0 @@ -version: "3" - -services: - - runtime-setup: - image: prometheus:22.04-main - build: - args: - base_image: "swiftlang/swift:nightly-main-jammy" - - documentation-check: - image: prometheus:22.04-main - - test: - image: prometheus:22.04-main - environment: - - IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error - #- SANITIZER_ARG=--sanitize=thread - - shell: - image: prometheus:22.04-main diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml deleted file mode 100644 index 26b0b41..0000000 --- a/docker/docker-compose.yaml +++ /dev/null @@ -1,42 +0,0 @@ -# this file is not designed to be run directly -# instead, use the docker-compose.. files -# eg docker-compose -f docker/docker-compose.yaml -f docker/docker-compose.2204.57.yaml run test -version: "3" - -services: - - runtime-setup: - image: prometheus:default - build: - context: . - dockerfile: Dockerfile - - common: &common - image: prometheus:default - depends_on: [runtime-setup] - volumes: - - ~/.ssh:/root/.ssh - - ..:/code:z - working_dir: /code - cap_drop: - - CAP_NET_RAW - - CAP_NET_BIND_SERVICE - - soundness: - <<: *common - command: /bin/bash -xcl "./scripts/soundness.sh" - - documentation-check: - <<: *common - command: /bin/bash -xcl "./scripts/check-docs.sh" - - test: - <<: *common - depends_on: [runtime-setup] - command: /bin/bash -xcl "swift test -Xswiftc -warnings-as-errors --enable-test-discovery $${SANITIZER_ARG-} $${IMPORT_CHECK_ARG-}" - - # util - - shell: - <<: *common - entrypoint: /bin/bash diff --git a/scripts/check_no_api_breakages.sh b/scripts/check_no_api_breakages.sh deleted file mode 100755 index 5ed0f07..0000000 --- a/scripts/check_no_api_breakages.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash -##===----------------------------------------------------------------------===## -## -## This source file is part of the SwiftPrometheus open source project -## -## Copyright (c) 2023 SwiftPrometheus project authors -## Licensed under Apache License v2.0 -## -## See LICENSE.txt for license information -## See CONTRIBUTORS.txt for the list of SwiftPrometheus project authors -## -## SPDX-License-Identifier: Apache-2.0 -## -##===----------------------------------------------------------------------===## -##===----------------------------------------------------------------------===## -## -## This source file is part of the SwiftNIO open source project -## -## Copyright (c) 2017-2020 Apple Inc. and the SwiftNIO project authors -## Licensed under Apache License v2.0 -## -## See LICENSE.txt for license information -## See CONTRIBUTORS.txt for the list of SwiftNIO project authors -## -## SPDX-License-Identifier: Apache-2.0 -## -##===----------------------------------------------------------------------===## - -set -eu - -function usage() { - echo >&2 "Usage: $0 REPO-GITHUB-URL NEW-VERSION OLD-VERSIONS..." - echo >&2 - echo >&2 "This script requires a Swift 5.6+ toolchain." - echo >&2 - echo >&2 "Examples:" - echo >&2 - echo >&2 "Check between main and tag 1.0.2 of prometheus:" - echo >&2 " $0 https://github.com/swift-server/swift-prometheus main 1.0.2" - echo >&2 - echo >&2 "Check between HEAD and commit 64cf63d7 using the provided toolchain:" - echo >&2 " xcrun --toolchain org.swift.5120190702a $0 ../some-local-repo HEAD 64cf63d7" -} - -if [[ $# -lt 3 ]]; then - usage - exit 1 -fi - -tmpdir=$(mktemp -d /tmp/.check-api_XXXXXX) -repo_url=$1 -new_tag=$2 -shift 2 - -repodir="$tmpdir/repo" -git clone "$repo_url" "$repodir" -git -C "$repodir" fetch -q origin '+refs/pull/*:refs/remotes/origin/pr/*' -cd "$repodir" -git checkout -q "$new_tag" - -for old_tag in "$@"; do - echo "Checking public API breakages from $old_tag to $new_tag" - - swift package diagnose-api-breaking-changes "$old_tag" -done - -echo done diff --git a/scripts/generate_contributors_list.sh b/scripts/generate_contributors_list.sh deleted file mode 100755 index bbba477..0000000 --- a/scripts/generate_contributors_list.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -##===----------------------------------------------------------------------===## -## -## This source file is part of the SwiftPrometheus open source project -## -## Copyright (c) 2023 SwiftPrometheus project authors -## Licensed under Apache License v2.0 -## -## See LICENSE.txt for license information -## See CONTRIBUTORS.txt for the list of SwiftPrometheus project authors -## -## SPDX-License-Identifier: Apache-2.0 -## -##===----------------------------------------------------------------------===## -##===----------------------------------------------------------------------===## -## -## This source file is part of the SwiftNIO open source project -## -## Copyright (c) 2017-2019 Apple Inc. and the SwiftNIO project authors -## Licensed under Apache License v2.0 -## -## See LICENSE.txt for license information -## See CONTRIBUTORS.txt for the list of SwiftNIO project authors -## -## SPDX-License-Identifier: Apache-2.0 -## -##===----------------------------------------------------------------------===## - -set -eu -here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -contributors=$( cd "$here"/.. && git shortlog -es | cut -f2 | sed 's/^/- /' ) - -cat > "$here/../CONTRIBUTORS.txt" <<- EOF - For the purpose of tracking copyright, this is the list of individuals and - organizations who have contributed source code to RediStack. - - For employees of an organization/company where the copyright of work done - by employees of that company is held by the company itself, only the company - needs to be listed here. - - ## COPYRIGHT HOLDERS - - - Apple Inc. (all contributors with '@apple.com') - - Globant Inc. (all contributors with '@globant.com') - - ### Contributors - - $contributors - - **Updating this list** - - Please do not edit this file manually. It is generated using \`./scripts/generate_contributors_list.sh\`. If a name is misspelled or appearing multiple times: add an entry in \`./.mailmap\` -EOF diff --git a/scripts/soundness.sh b/scripts/soundness.sh deleted file mode 100755 index d6a884e..0000000 --- a/scripts/soundness.sh +++ /dev/null @@ -1,149 +0,0 @@ -#!/bin/bash -##===----------------------------------------------------------------------===## -## -## This source file is part of the SwiftPrometheus open source project -## -## Copyright (c) 2023 SwiftPrometheus project authors -## Licensed under Apache License v2.0 -## -## See LICENSE.txt for license information -## See CONTRIBUTORS.txt for the list of SwiftPrometheus project authors -## -## SPDX-License-Identifier: Apache-2.0 -## -##===----------------------------------------------------------------------===## - -set -eu -here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -function replace_acceptable_years() { - # this needs to replace all acceptable forms with 'YEARS' - sed -e 's/20[12][0-9]-20[12][0-9]/YEARS/' -e 's/20[12][0-9]/YEARS/' -} - -printf "=> Checking for unacceptable language... " -# This greps for unacceptable terminology. The square bracket[s] are so that -# "git grep" doesn't find the lines that greps :). -unacceptable_terms=( - -e blacklis[t] - -e whitelis[t] - -e slav[e] - -e sanit[y] -) -if git grep --color=never -i "${unacceptable_terms[@]}" > /dev/null; then - printf "\033[0;31mUnacceptable language found.\033[0m\n" - git grep -i "${unacceptable_terms[@]}" - exit 1 -fi -printf "\033[0;32mokay.\033[0m\n" - -printf "=> Checking format... " -output=$(swift-format lint --configuration .swift-format --recursive Sources Tests 2>&1) # Capture the command's output -if [ -n "$output" ]; then - printf "\033[0;31mformatting issues!\033[0m\n" - exit 1 -else - printf "\033[0;32mokay.\033[0m\n" -fi - -printf "=> Checking license headers\n" -tmp=$(mktemp /tmp/.prometheus-soundness_XXXXXX) - -for language in swift-or-c bash dtrace; do - printf " * $language... " - declare -a matching_files - declare -a exceptions - expections=( ) - matching_files=( -name '*' ) - case "$language" in - swift-or-c) - exceptions=( -name Package.swift -o -name 'Package@swift*.swift' ) - matching_files=( -name '*.swift' -o -name '*.c' -o -name '*.h' ) - cat > "$tmp" <<"EOF" -//===----------------------------------------------------------------------===// -// -// This source file is part of the SwiftPrometheus open source project -// -// Copyright (c) YEARS SwiftPrometheus project authors -// Licensed under Apache License v2.0 -// -// See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of SwiftPrometheus project authors -// -// SPDX-License-Identifier: Apache-2.0 -// -//===----------------------------------------------------------------------===// -EOF - ;; - bash) - matching_files=( -name '*.sh' ) - cat > "$tmp" <<"EOF" -#!/bin/bash -##===----------------------------------------------------------------------===## -## -## This source file is part of the SwiftPrometheus open source project -## -## Copyright (c) YEARS SwiftPrometheus project authors -## Licensed under Apache License v2.0 -## -## See LICENSE.txt for license information -## See CONTRIBUTORS.txt for the list of SwiftPrometheus project authors -## -## SPDX-License-Identifier: Apache-2.0 -## -##===----------------------------------------------------------------------===## -EOF - ;; - dtrace) - matching_files=( -name '*.d' ) - cat > "$tmp" <<"EOF" -#!/usr/sbin/dtrace -q -s -/*===----------------------------------------------------------------------===* - * - * This source file is part of the SwiftPrometheus open source project - * - * Copyright (c) YEARS SwiftPrometheus project authors - * Licensed under Apache License v2.0 - * - * See LICENSE.txt for license information - * See CONTRIBUTORS.txt for the list of SwiftPrometheus project authors - * - * SPDX-License-Identifier: Apache-2.0 - * - *===----------------------------------------------------------------------===*/ -EOF - ;; - *) - echo >&2 "ERROR: unknown language '$language'" - ;; - esac - - expected_lines=$(cat "$tmp" | wc -l) - expected_sha=$(cat "$tmp" | shasum) - - ( - cd "$here/.." - find . \ - \( \! -path './.build/*' -a \ - \( "${matching_files[@]}" \) -a \ - \( \! \( "${exceptions[@]}" \) \) \) | while read line; do - if [[ "$(cat "$line" | replace_acceptable_years | head -n $expected_lines | shasum)" != "$expected_sha" ]]; then - printf "\033[0;31mmissing headers in file '$line'!\033[0m\n" - diff -u <(cat "$line" | replace_acceptable_years | head -n $expected_lines) "$tmp" - exit 1 - fi - done - printf "\033[0;32mokay.\033[0m\n" - ) -done - -rm "$tmp" - -# This checks for the umbrella NIO module. -printf "=> Checking for imports of umbrella NIO module... " -if git grep --color=never -i "^[ \t]*import \+NIO[ \t]*$" > /dev/null; then - printf "\033[0;31mUmbrella imports found.\033[0m\n" - git grep -i "^[ \t]*import \+NIO[ \t]*$" - exit 1 -fi -printf "\033[0;32mokay.\033[0m\n"