Skip to content

Commit

Permalink
Migrate to GitHub Actions reusable workflows (2) (#74)
Browse files Browse the repository at this point in the history
* Prepare repo for new GHA checks

Motivation:

Migrate to GitHub Actions reusable workflows (2)

Modifications:

* Add GHA PR label checks
* Add GHA benchmarks checks
* Satisfy soundness checks

Result:

New soundness checks should be green and ready for adoption

* review comments
  • Loading branch information
rnro authored Oct 15, 2024
1 parent 7faebca commit d016643
Show file tree
Hide file tree
Showing 23 changed files with 81 additions and 362 deletions.
18 changes: 6 additions & 12 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,25 @@ jobs:
name: Soundness
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
with:
# These are set to false to stage this in with the old CI.
# A follow-up PR will cut them over.
api_breakage_check_enabled: false
broken_symlink_check_enabled: false
docs_check_enabled: false
format_check_enabled: false
license_header_check_enabled: false
license_header_check_project_name: "SwiftASN1"
shell_check_enabled: false
unacceptable_language_check_enabled: false
unit-tests:
name: Unit tests
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
with:
linux_5_8_enabled: false
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_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"

benchmarks:
name: Benchmarks
uses: apple/swift-nio/.github/workflows/benchmarks.yml@main
with:
benchmark_package_path: "Benchmarks"

cxx-interop:
name: Cxx interop
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main
with:
linux_5_8_enabled: false

swift-6-language-mode:
name: Swift 6 Language Mode
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/pull_request_label.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"mallocCountTotal" : 565,
"memoryLeaked" : 0,
"readSyscalls" : 0,
"writeSyscalls" : 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"mallocCountTotal" : 572,
"memoryLeaked" : 0,
"readSyscalls" : 0,
"writeSyscalls" : 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"mallocCountTotal" : 967,
"memoryLeaked" : 0,
"readSyscalls" : 0,
"writeSyscalls" : 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"mallocCountTotal" : 565,
"memoryLeaked" : 0,
"readSyscalls" : 0,
"writeSyscalls" : 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"mallocCountTotal" : 572,
"memoryLeaked" : 0,
"readSyscalls" : 0,
"writeSyscalls" : 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"mallocCountTotal" : 967,
"memoryLeaked" : 0,
"readSyscalls" : 0,
"writeSyscalls" : 0
}
26 changes: 4 additions & 22 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,11 @@ We require that your commit messages match our template. The easiest way to do t

git config commit.template dev/git.commit.template

### Run `./scripts/soundness.sh`
### Run CI checks locally

The scripts directory contains a [soundness.sh script](https://github.com/apple/swift-asn1/blob/main/scripts/soundness.sh)
that enforces additional checks, like license headers and formatting style.

Please make sure to `./scripts/soundness.sh` before pushing a change upstream, otherwise it is likely the PR validation will fail
on minor changes such as a missing `self.` or similar formatting issues.

For frequent contributors, we recommend adding the script as a [git pre-push hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks), which you can do via executing the following command in the project root directory:

```bash
cat << EOF > .git/hooks/pre-push
if [[ -f "scripts/soundness.sh" ]]; then
scripts/soundness.sh
fi
EOF
```

Which makes the script execute, and only allow the `git push` to complete if the check has passed.

In the case of formatting issues, you can then `git add` the formatting changes, and attempt the push again.
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/apple/swift-asn1. Make sure the CI passes, and then wait for code review.
Please open a pull request at [https://github.com/apple/swift-asn1](https://github.com/apple/swift-asn1). Make sure the CI passes, and then wait for code review.
13 changes: 2 additions & 11 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import PackageDescription
import class Foundation.ProcessInfo

let upcomingFeatureSwiftSettings: [SwiftSetting] = [
.enableUpcomingFeature("ExistentialAny"),
.enableUpcomingFeature("ExistentialAny")
]

let package = Package(
Expand All @@ -35,15 +35,6 @@ let package = Package(
name: "SwiftASN1Tests",
dependencies: ["SwiftASN1"],
swiftSettings: upcomingFeatureSwiftSettings
)
),
]
)

// If the `SWIFTCI_USE_LOCAL_DEPS` environment variable is set,
// we're building in the Swift.org CI system alongside other projects in the Swift toolchain and
// we can depend on local versions of our dependencies instead of fetching them remotely.
if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
package.dependencies += [
.package(url: "https://github.com/swiftlang/swift-docc-plugin", from: "1.0.0"),
]
}
3 changes: 1 addition & 2 deletions Sources/SwiftASN1/ASN1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
//
//===----------------------------------------------------------------------===//


@available(*, unavailable)
extension ASN1: Sendable { }
extension ASN1: Sendable {}

public enum ASN1 {}

Expand Down
6 changes: 3 additions & 3 deletions Sources/SwiftASN1/BER.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ extension BER {
/// Constructs an array of `T` elements parsed from the set.
///
/// - parameters:
/// - of: An optional parameter to express the type to decode.
/// - type: An optional parameter to express the type to decode.
/// - identifier: The ``ASN1Identifier`` that the SET OF is expected to have.
/// - rootNode: The ``ASN1Node`` to parse
/// - returns: An array of elements representing the elements in the sequence.
Expand Down Expand Up @@ -511,7 +511,7 @@ public protocol BERParseable: DERParseable {
/// expected to initialize themselves if possible, or to throw if they cannot.
///
/// - parameters:
/// - berEncoded: The ASN.1 node representing this object.
/// - node: The ASN.1 node representing this object.
init(berEncoded node: ASN1Node) throws
}

Expand Down Expand Up @@ -588,7 +588,7 @@ extension BERImplicitlyTaggable {
/// to ``BERImplicitlyTaggable/init(berEncoded:withIdentifier:)``.
///
/// - parameters:
/// - berEncoded: The sequence of nodes that make up this object's parent. The first node in this collection
/// - sequenceNodeIterator: The sequence of nodes that make up this object's parent. The first node in this collection
/// will be used to construct this object.
/// - identifier: The ASN.1 identifier that `berEncoded` is expected to have.
@inlinable
Expand Down
1 change: 0 additions & 1 deletion Sources/SwiftASN1/Basic ASN1 Types/TimeUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//


@available(*, unavailable)
extension TimeUtilities: Sendable {}

Expand Down
8 changes: 4 additions & 4 deletions Sources/SwiftASN1/DER.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ extension DER {
/// Constructs an array of `T` elements parsed from the set.
///
/// - parameters:
/// - of: An optional parameter to express the type to decode.
/// - type: An optional parameter to express the type to decode.
/// - identifier: The ``ASN1Identifier`` that the SET OF is expected to have.
/// - rootNode: The ``ASN1Node`` to parse
/// - returns: An array of elements representing the elements in the sequence.
Expand Down Expand Up @@ -929,7 +929,7 @@ public protocol DERParseable {
/// expected to initialize themselves if possible, or to throw if they cannot.
///
/// - parameters:
/// - derEncoded: The ASN.1 node representing this object.
/// - node: The ASN.1 node representing this object.
init(derEncoded node: ASN1Node) throws
}

Expand All @@ -940,7 +940,7 @@ extension DERParseable {
/// to ``DERParseable/init(derEncoded:)-7tumk``.
///
/// - parameters:
/// - derEncoded: The sequence of nodes that make up this object's parent. The first node in this collection
/// - sequenceNodeIterator: The sequence of nodes that make up this object's parent. The first node in this collection
/// will be used to construct this object.
@inlinable
public init(derEncoded sequenceNodeIterator: inout ASN1NodeCollection.Iterator) throws {
Expand Down Expand Up @@ -1022,7 +1022,7 @@ extension DERImplicitlyTaggable {
/// to ``DERImplicitlyTaggable/init(derEncoded:withIdentifier:)-7e88k``.
///
/// - parameters:
/// - derEncoded: The sequence of nodes that make up this object's parent. The first node in this collection
/// - sequenceNodeIterator: The sequence of nodes that make up this object's parent. The first node in this collection
/// will be used to construct this object.
/// - identifier: The ASN.1 identifier that `derEncoded` is expected to have.
@inlinable
Expand Down
2 changes: 1 addition & 1 deletion dev/update-benchmark-thresholds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ for f in 57 58 59 510 -nightly; do

docker_file=$(if [[ "$f" == "-nightly" ]]; then f=main; fi && ls "$target_repo/docker/docker-compose."*"$f"*".yaml")

docker-compose -f docker/docker-compose.yaml -f $docker_file run update-benchmark-baseline
docker-compose -f docker/docker-compose.yaml -f "$docker_file" run update-benchmark-baseline
done
4 changes: 2 additions & 2 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ services:

soundness:
<<: *common
command: /bin/bash -xcl "swift -version && uname -a && ./scripts/soundness.sh"
command: echo "skipping; moved to Github Actions"

test:
<<: *common
command: /bin/bash -xcl "swift $${SWIFT_TEST_VERB-test} $${WARN_AS_ERROR_ARG-} $${SANITIZER_ARG-} $${IMPORT_CHECK_ARG-} $${EXPLICIT_SENDABLE_ARG-} $${STRICT_CONCURRENCY_ARG} && cd Benchmarks && swift package benchmark baseline check --check-absolute-path Thresholds/$${SWIFT_VERSION-}/"
command: echo "skipping; moved to Github Actions"

update-benchmark-baseline:
<<: *common
Expand Down
40 changes: 1 addition & 39 deletions scripts/check_no_api_breakages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,42 +26,4 @@
##
##===----------------------------------------------------------------------===##

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.2+ toolchain."
echo >&2
echo >&2 "Examples:"
echo >&2
echo >&2 "Check between main and tag 2.1.1 of swift-asn1:"
echo >&2 " $0 https://github.com/apple/swift-asn1 main 2.1.1"
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
exit 0
54 changes: 0 additions & 54 deletions scripts/run-swift-format.sh

This file was deleted.

Loading

0 comments on commit d016643

Please sign in to comment.