File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Load diff This file was deleted.
Original file line number Diff line number Diff line change 3838 android:
3939 - 'platforms/android/**'
4040 - '.github/workflows/android-test.yml'
41- - '.github/workflows/android-license-headers.yml'
41+ - '.github/workflows/license-headers.yml'
42+ - 'scripts/check_license_headers.rb'
4243 - '.github/workflows/ci.yml'
4344 swift:
4445 - 'platforms/swift/**'
6162 web:
6263 - 'platforms/web/**'
6364 - '.github/workflows/web.yml'
64- - '.github/workflows/web-license-headers.yml'
65+ - '.github/workflows/license-headers.yml'
66+ - 'scripts/check_license_headers.rb'
6567 - '.github/actions/setup/**'
6668 - '.github/workflows/ci.yml'
6769
7577 name : Android
7678 needs : changes
7779 if : needs.changes.outputs.android == 'true'
78- uses : ./.github/workflows/android-license-headers.yml
80+ uses : ./.github/workflows/license-headers.yml
81+ with :
82+ target : platforms/android
7983
8084 swift-test-package :
8185 name : Swift
@@ -147,7 +151,9 @@ jobs:
147151 name : Web
148152 needs : changes
149153 if : needs.changes.outputs.web == 'true'
150- uses : ./.github/workflows/web-license-headers.yml
154+ uses : ./.github/workflows/license-headers.yml
155+ with :
156+ target : platforms/web/src
151157
152158 # Single required status check for branch protection.
153159 # Passes when every relevant platform job either succeeded or was skipped
Original file line number Diff line number Diff line change 1+ name : Check License Headers
2+
3+ on :
4+ workflow_call :
5+ inputs :
6+ target :
7+ description : Directory to scan, relative to repo root (e.g. platforms/android)
8+ required : true
9+ type : string
10+
11+ permissions :
12+ contents : read
13+
14+ jobs :
15+ check :
16+ runs-on : ubuntu-latest
17+ timeout-minutes : 5
18+ steps :
19+ - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
20+ with :
21+ submodules : true
22+
23+ - uses : ruby/setup-ruby@6aaa311d81eba98ae12eaffbcb63296ace0efcde # v1.307.0
24+ with :
25+ ruby-version : ' 3.3.6'
26+
27+ - name : Check license headers
28+ run : ruby scripts/check_license_headers.rb "${{ inputs.target }}"
Load diff This file was deleted.
Original file line number Diff line number Diff line change 6464 run : pnpm verify
6565
6666 - name : Check license headers
67- run : . /scripts/check_license_headers.rb
67+ run : ruby "$GITHUB_WORKSPACE /scripts/check_license_headers.rb" platforms/web/src
6868
6969 - name : Pack and inspect contents
7070 run : |
Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ jobs:
100100 run : pnpm verify
101101
102102 - name : Check license headers
103- run : . /scripts/check_license_headers.rb
103+ run : ruby "$GITHUB_WORKSPACE /scripts/check_license_headers.rb" platforms/web/src
104104
105105 - name : Pack and inspect contents
106106 run : |
Original file line number Diff line number Diff line change 7676 " PRs " : " https://github.com/Shopify/checkout-kit/pulls"
7777
7878check :
79- android-license-headers : cd platforms/android && ./scripts/check_license_headers.rb
79+ android-license-headers : ./scripts/check_license_headers.rb platforms/android
8080 android-detekt : cd platforms/android && ./gradlew detekt
8181 android-lint : cd platforms/android && ./gradlew lintRelease
8282 swift-lint : cd platforms/swift && ./Scripts/lint
@@ -164,14 +164,14 @@ commands:
164164 desc : Run all Android checks (license headers, detekt, android lint)
165165 run : |
166166 set -e
167+ ./scripts/check_license_headers.rb platforms/android
167168 cd platforms/android
168- ./scripts/check_license_headers.rb
169169 ./gradlew detekt
170170 ./gradlew lintRelease
171171 subcommands :
172172 license-headers :
173173 desc : Check MIT license headers in source files
174- run : cd platforms/android && ./scripts/check_license_headers.rb
174+ run : ./scripts/check_license_headers.rb platforms/android
175175 detekt :
176176 desc : Run detekt static analysis
177177 run : cd platforms/android && ./gradlew detekt
Load diff This file was deleted.
Load diff This file was deleted.
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env ruby
2+ require 'find'
3+
4+ # Extensions and excludes are baked in — this script is opinionated for the
5+ # platforms in this repo. Add to these lists when introducing a new language
6+ # or build-output directory that should be covered.
7+ EXTENSIONS = %w[ .kt .kts .ts .tsx ] . freeze
8+ EXCLUDES = %w[
9+ */build/generated/*
10+ */build/*
11+ *.test.ts
12+ *.test.tsx
13+ *.d.ts
14+ ] . freeze
15+
16+ abort 'Usage: check_license_headers.rb <root>' if ARGV . empty?
17+
18+ root = File . expand_path ( ARGV [ 0 ] )
19+ abort "error: #{ ARGV [ 0 ] } is not a directory" unless File . directory? ( root )
20+
21+ missing = [ ]
22+
23+ Find . find ( root ) do |path |
24+ next unless File . file? ( path )
25+ next unless EXTENSIONS . any? { |ext | path . end_with? ( ext ) }
26+ next if EXCLUDES . any? { |pattern | File . fnmatch? ( pattern , path ) }
27+
28+ lines = File . readlines ( path )
29+ has_header = lines [ 0 ] &.start_with? ( '/*' ) && lines [ 1 ] &.include? ( 'MIT License' )
30+ missing << path unless has_header
31+ end
32+
33+ if missing . empty?
34+ puts 'No missing license headers found'
35+ exit 0
36+ end
37+
38+ puts "#{ missing . size } file(s) missing license headers:"
39+ missing . each { |f | puts " #{ f . sub ( "#{ root } /" , '' ) } " }
40+ exit 1
You can’t perform that action at this time.
0 commit comments