Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:
types: [opened, reopened, synchronize]

jobs:
shell_tests:
name: Shell Tests
uses: ./.github/workflows/shell_tests.yml

tests_with_docker_embedded_swift:
name: Test Embedded Swift SDKs
uses: ./.github/workflows/swift_package_test.yml
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/scripts/check-license-header.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,20 @@ while IFS= read -r file_path; do
| sed -E -e 's/20[12][0123456789] ?[-–] ?20[12][0123456789]/YEARS/' -e 's/20[12][0123456789]/YEARS/' \
)

if ! diff -u \
if ! diff_output=$(diff -u \
--label "Expected header" <(echo "${expected_file_header}") \
--label "${file_path}" <(echo "${normalized_file_header}")
--label "${file_path}" <(echo "${normalized_file_header}"))
then
expected_file_header_without_contributors=$(echo "${expected_file_header}" | sed '/CONTRIBUTORS\.txt/d')
normalized_file_header_without_contributors=$(echo "${normalized_file_header}" | sed '/CONTRIBUTORS\.txt/d')
if [ "${expected_file_header}" != "${expected_file_header_without_contributors}" ] \
&& diff -u \
--label "Expected header" <(echo "${expected_file_header_without_contributors}") \
--label "${file_path}" <(echo "${normalized_file_header_without_contributors}") > /dev/null
then
continue
fi
echo "${diff_output}"
paths_with_missing_license+=("${file_path} ")
fi
done <<< "$file_paths"
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/shell_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Shell Tests

on:
workflow_call:

permissions:
contents: read

jobs:
license-header-check:
name: License header check tests
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Test license header check
run: bash tests/check-license-header.sh
58 changes: 58 additions & 0 deletions tests/check-license-header.sh

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we configure the pull request CI to run these shell tests?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@FranzBusch I have added a shell_tests job, based on the similar template as other CI jobs in this repo.

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash
##===----------------------------------------------------------------------===##
##
## This source file is part of the Swift.org open source project
##
## Copyright (c) 2026 Apple Inc. and the Swift project authors
## Licensed under Apache License v2.0 with Runtime Library Exception
##
## See https://swift.org/LICENSE.txt for license information
##
##===----------------------------------------------------------------------===##

set -euo pipefail

repo_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
tmpdir=$(mktemp -d)
trap 'rm -rf "${tmpdir}"' EXIT

mkdir -p "${tmpdir}/.github/workflows/scripts"
cp "${repo_root}/.github/workflows/scripts/check-license-header.sh" "${tmpdir}/.github/workflows/scripts/check-license-header.sh"

cd "${tmpdir}"
git init -q

cat > WithContributors.swift <<'EOF'
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Logging API open source project
//
// Copyright (c) 2025 Apple Inc. and the Swift Logging API project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift Logging API project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
EOF

cat > WithoutContributors.swift <<'EOF'
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Logging API open source project
//
// Copyright (c) 2025 Apple Inc. and the Swift Logging API project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
EOF

git add WithContributors.swift WithoutContributors.swift

PROJECT_NAME="Swift Logging API" .github/workflows/scripts/check-license-header.sh
Loading