1
1
#! /bin/bash
2
+ # #===----------------------------------------------------------------------===##
3
+ # #
4
+ # # This source file is part of the VS Code Swift open source project
5
+ # #
6
+ # # Copyright (c) 2021 the VS Code Swift project authors
7
+ # # Licensed under Apache License v2.0
8
+ # #
9
+ # # See LICENSE.txt for license information
10
+ # # See CONTRIBUTORS.txt for the list of VS Code Swift project authors
11
+ # #
12
+ # # SPDX-License-Identifier: Apache-2.0
13
+ # #
14
+ # #===----------------------------------------------------------------------===##
2
15
3
- # This file is supplanted by the GitHub Actions enabled in
4
- # https://github.com/swiftlang/vscode-swift/pull/1159,
5
- # remove this file once that has been merged.
6
- exit 0
16
+ if [[ " $1 " != " --force-run" ]]; then
17
+ # This file is supplanted by the GitHub Actions enabled in
18
+ # https://github.com/swiftlang/vscode-swift/pull/1159,
19
+ # Until https://github.com/swiftlang/vscode-swift/pull/1176 is
20
+ # merged we still run the licence check here via the docker/test.sh
21
+ # with the --force-run flag, and the soundness Jenkins job is skipped
22
+ # with this exit 0. This lets us run this licence check in the GitHub Actions
23
+ # until the standard licence check in GH Actions can be used.
24
+ exit 0
25
+ fi
26
+
27
+ set -eu
28
+ here=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
29
+
30
+ function replace_acceptable_years() {
31
+ # this needs to replace all acceptable forms with 'YEARS'
32
+ sed -e ' s/20[12][0123456789]-20[12][0123456789]/YEARS/' -e ' s/20[12][0123456789]/YEARS/'
33
+ }
34
+
35
+ printf " => Checking license headers... "
36
+ tmp=$( mktemp /tmp/.vscode-swift-soundness_XXXXXX)
37
+
38
+ for language in typescript-or-javascript bash; do
39
+ declare -a matching_files
40
+ matching_files=( -name ' *' )
41
+ case " $language " in
42
+ typescript-or-javascript)
43
+ matching_files=( -name ' *.js' -o -name ' *.ts' )
44
+ cat > " $tmp " << "EOF "
45
+ //===----------------------------------------------------------------------===//
46
+ //
47
+ // This source file is part of the VS Code Swift open source project
48
+ //
49
+ // Copyright (c) YEARS the VS Code Swift project authors
50
+ // Licensed under Apache License v2.0
51
+ //
52
+ // See LICENSE.txt for license information
53
+ // See CONTRIBUTORS.txt for the list of VS Code Swift project authors
54
+ //
55
+ // SPDX-License-Identifier: Apache-2.0
56
+ //
57
+ //===----------------------------------------------------------------------===//
58
+ EOF
59
+ ;;
60
+ bash)
61
+ matching_files=( -name ' *.sh' )
62
+ cat > " $tmp " << "EOF "
63
+ #!/bin/bash
64
+ ##===----------------------------------------------------------------------===##
65
+ ##
66
+ ## This source file is part of the VS Code Swift open source project
67
+ ##
68
+ ## Copyright (c) YEARS the VS Code Swift project authors
69
+ ## Licensed under Apache License v2.0
70
+ ##
71
+ ## See LICENSE.txt for license information
72
+ ## See CONTRIBUTORS.txt for the list of VS Code Swift project authors
73
+ ##
74
+ ## SPDX-License-Identifier: Apache-2.0
75
+ ##
76
+ ##===----------------------------------------------------------------------===##
77
+ EOF
78
+ ;;
79
+ * )
80
+ echo >&2 " ERROR: unknown language '$language '"
81
+ ;;
82
+ esac
83
+
84
+ expected_lines=$( cat " $tmp " | wc -l)
85
+ expected_sha=$( cat " $tmp " | shasum)
86
+
87
+ (
88
+ cd " $here /.."
89
+ {
90
+ find . \
91
+ \( \! -path ' ./.build/*' -a \
92
+ \( \! -path ' ./node_modules/*' -a \
93
+ \( \! -path ' ./out/*' -a \
94
+ \( \! -path ' ./.vscode-test/*' -a \
95
+ \( \! -path ' ./docker/*' -a \
96
+ \( \! -path ' ./dist/*' -a \
97
+ \( \! -path ' ./assets/*' -a \
98
+ \( \! -path ' ./coverage/*' -a \
99
+ \( " ${matching_files[@]} " \) \
100
+ \) \) \) \) \) \) \) \)
101
+
102
+ if [[ " $language " = bash ]]; then
103
+ # add everything with a shell shebang too
104
+ git grep --full-name -l ' #!/bin/bash'
105
+ git grep --full-name -l ' #!/bin/sh'
106
+ fi
107
+ } | while read line; do
108
+ if [[ " $( cat " $line " | replace_acceptable_years | head -n $expected_lines | shasum) " != " $expected_sha " ]]; then
109
+ printf " \033[0;31mmissing headers in file '$line '!\033[0m\n"
110
+ diff -u <( cat " $line " | replace_acceptable_years | head -n $expected_lines ) " $tmp "
111
+ exit 1
112
+ fi
113
+ done
114
+ printf " \033[0;32mokay.\033[0m\n"
115
+ )
116
+ done
117
+
118
+ rm " $tmp "
119
+
120
+ # printf "=> Checking for broken links in documentation... "
121
+ # find . -name node_modules -prune -o -name \*.md -print0 | xargs -0 -n1 npx markdown-link-check
122
+ # printf "\033[0;32mokay.\033[0m\n"
0 commit comments