Skip to content

Commit f0e61d3

Browse files
authored
Add Super-Linter (#21)
1 parent c7bc112 commit f0e61d3

File tree

11 files changed

+242
-209
lines changed

11 files changed

+242
-209
lines changed

.github/workflows/lint.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Lint
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- ".github/workflows/swiftlint.yml"
7+
- ".swiftlint.yml"
8+
- "**/*.swift"
9+
10+
jobs:
11+
Super-Linter:
12+
permissions:
13+
contents: write
14+
statuses: write
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
- name: Super-Linter
21+
uses: super-linter/[email protected]
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
DISABLE_ERRORS: true
25+
FIX_SHELL_SHFMT: true
26+
FIX_YAML_PRETTIER: true
27+
FIX_MARKDOWN_PRETTIER: true
28+
FIX_JSON_PRETTIER: true
29+
- name: Commit and push linting fixes
30+
if: >
31+
github.event_name == 'pull_request' &&
32+
github.ref_name != github.event.repository.default_branch
33+
uses: stefanzweifel/git-auto-commit-action@v5
34+
with:
35+
branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }}
36+
file_pattern: "*.sh *.yml *.md *.json"
37+
commit_message: "chore: fix linting issues"
38+
commit_user_name: super-linter
39+
commit_user_email: [email protected]
40+
41+
SwiftLint:
42+
runs-on: macos-latest
43+
needs: Super-Linter
44+
steps:
45+
- uses: actions/checkout@v3
46+
- uses: swift-actions/setup-swift@v2
47+
with:
48+
swift-version: "5"
49+
- name: GitHub Actions for SwiftLint
50+
uses: sinoru/actions-swiftlint@v6
51+
with:
52+
swiftlint-version: "0.57.1"

.github/workflows/promote-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Promote Pre-release to Release
22

33
on:
44
schedule:
5-
- cron: '30 23 * * *'
5+
- cron: "30 23 * * *"
66
workflow_dispatch:
77

88
jobs:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Release
33
on:
44
push:
55
tags:
6-
- '*'
6+
- "*"
77
branches:
88
- main
99
pull_request:

.github/workflows/swiftlint.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 129 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
name: Build and Test
22

3-
on:
3+
on:
44
push:
55
paths:
6-
- '.github/workflows/test-and-coverage.yml'
7-
- '.test-and-coverage.yml'
8-
- '**/*.sh'
9-
- '**/*.swift'
10-
- 'mpvx/**'
11-
- 'mpvx.xcodeproj/**'
6+
- ".github/workflows/test-and-coverage.yml"
7+
- ".test-and-coverage.yml"
8+
- "**/*.sh"
9+
- "**/*.swift"
10+
- "mpvx/**"
11+
- "mpvx.xcodeproj/**"
1212

1313
jobs:
1414
build_and_test:
@@ -19,136 +19,136 @@ jobs:
1919
fail-fast: false
2020
runs-on: ${{ matrix.os }}
2121
steps:
22-
- uses: actions/checkout@v3
23-
with:
24-
fetch-depth: 0
25-
- uses: maxim-lobanov/setup-xcode@v1
26-
with:
27-
xcode-version: latest-stable
28-
- name: Install Dependencies
29-
run: |
30-
brew install --formula mpv
31-
which mpv
32-
brew info mpv --formula
33-
- name: Setup
34-
run: |
35-
./setup.sh
36-
- name: Run Tests
37-
run: |
38-
xcodebuild clean test \
39-
-scheme mpvx \
40-
-configuration Debug \
41-
-derivedDataPath build \
42-
-destination "platform=macOS,arch=${{ matrix.arch }}" \
43-
-resultBundlePath "artifacts/ResultBundle-${{ matrix.os }}-${{ matrix.arch }}.xcresult"
44-
- name: Upload Result Bundle
45-
uses: actions/upload-artifact@v4
46-
with:
47-
name: "ResultBundle-${{ matrix.os }}-${{ matrix.arch }}.xcresult"
48-
path: "artifacts/ResultBundle-${{ matrix.os }}-${{ matrix.arch }}.xcresult"
49-
if: always()
50-
- name: Install Dependencies
51-
run: |
52-
brew install --formula xcresultparser
53-
- name: Convert Merged Result to Coverage
54-
run: |
55-
xcresultparser \
56-
--output-format cobertura \
57-
artifacts/ResultBundle-${{ matrix.os }}-${{ matrix.arch }}.xcresult > artifacts/coverage-${{ matrix.os }}-${{ matrix.arch }}.xml
58-
- name: Upload Coverage to Codecov
59-
uses: codecov/codecov-action@v5
60-
with:
61-
files: artifacts/coverage.xml
62-
token: ${{ secrets.CODECOV_TOKEN }}
63-
flags: ${{ matrix.os }}_${{ matrix.arch }}_tests
64-
fail_ci_if_error: true
22+
- uses: actions/checkout@v3
23+
with:
24+
fetch-depth: 0
25+
- uses: maxim-lobanov/setup-xcode@v1
26+
with:
27+
xcode-version: latest-stable
28+
- name: Install Dependencies
29+
run: |
30+
brew install --formula mpv
31+
which mpv
32+
brew info mpv --formula
33+
- name: Setup
34+
run: |
35+
./setup.sh
36+
- name: Run Tests
37+
run: |
38+
xcodebuild clean test \
39+
-scheme mpvx \
40+
-configuration Debug \
41+
-derivedDataPath build \
42+
-destination "platform=macOS,arch=${{ matrix.arch }}" \
43+
-resultBundlePath "artifacts/ResultBundle-${{ matrix.os }}-${{ matrix.arch }}.xcresult"
44+
- name: Upload Result Bundle
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: "ResultBundle-${{ matrix.os }}-${{ matrix.arch }}.xcresult"
48+
path: "artifacts/ResultBundle-${{ matrix.os }}-${{ matrix.arch }}.xcresult"
49+
if: always()
50+
- name: Install Dependencies
51+
run: |
52+
brew install --formula xcresultparser
53+
- name: Convert Merged Result to Coverage
54+
run: |
55+
xcresultparser \
56+
--output-format cobertura \
57+
artifacts/ResultBundle-${{ matrix.os }}-${{ matrix.arch }}.xcresult > artifacts/coverage-${{ matrix.os }}-${{ matrix.arch }}.xml
58+
- name: Upload Coverage to Codecov
59+
uses: codecov/codecov-action@v5
60+
with:
61+
files: artifacts/coverage.xml
62+
token: ${{ secrets.CODECOV_TOKEN }}
63+
flags: ${{ matrix.os }}_${{ matrix.arch }}_tests
64+
fail_ci_if_error: true
6565

6666
merge:
6767
runs-on: macos-latest
6868
needs: build_and_test
6969
steps:
70-
- name: List and download all .xcresult artifacts
71-
run: |
72-
# Get a list of all artifacts for the current run
73-
ARTS=$(curl -s \
74-
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
75-
-H "Accept: application/vnd.github+json" \
76-
"https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts" \
77-
| jq -r '.artifacts[] | select(.name | endswith(".xcresult")) | [.name, .archive_download_url] | @tsv')
78-
mkdir -p artifacts
79-
# Loop through each artifact and download it
80-
while IFS=$'\t' read -r NAME URL; do
81-
echo "Downloading artifact: $NAME"
82-
curl -L \
70+
- name: List and download all .xcresult artifacts
71+
run: |
72+
# Get a list of all artifacts for the current run
73+
ARTS=$(curl -s \
8374
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
84-
-o "$NAME.zip" "$URL"
85-
unzip "$NAME.zip" -d "artifacts/$NAME"
86-
rm "$NAME.zip"
87-
done <<< "$ARTS"
88-
- uses: maxim-lobanov/setup-xcode@v1
89-
with:
90-
xcode-version: latest-stable
91-
- name: Merge Result Bundles
92-
run: |
93-
# Dynamically find all .xcresult directories in artifacts
94-
XCBUNDLES=($(find artifacts -type d -name '*.xcresult'))
95-
if [ ${#XCBUNDLES[@]} -gt 1 ]; then
96-
xcrun xcresulttool merge "${XCBUNDLES[@]}" --output-path artifacts/ResultBundle.xcresult
97-
else
98-
# If there's only one bundle, just rename it as the merged output
99-
mv "${XCBUNDLES[0]}" artifacts/ResultBundle.xcresult
100-
fi
101-
- name: Cleanup Old Artifacts from GitHub
102-
run: |
103-
curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
104-
-H 'Accept: application/vnd.github+json' \
105-
"https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts" \
106-
| jq -r '.artifacts[] | select(.name | endswith(".xcresult")) | .id' \
107-
| while read artifact_id; do
108-
echo "Deleting artifact ID: $artifact_id"
109-
curl -X DELETE -s \
110-
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
111-
-H 'Accept: application/vnd.github+json' \
112-
"https://api.github.com/repos/${{ github.repository }}/actions/artifacts/$artifact_id"
113-
done
114-
- name: Re-upload Merged Result
115-
uses: actions/upload-artifact@v4
116-
with:
117-
name: ResultBundle.xcresult
118-
path: artifacts/ResultBundle.xcresult
75+
-H "Accept: application/vnd.github+json" \
76+
"https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts" \
77+
| jq -r '.artifacts[] | select(.name | endswith(".xcresult")) | [.name, .archive_download_url] | @tsv')
78+
mkdir -p artifacts
79+
# Loop through each artifact and download it
80+
while IFS=$'\t' read -r NAME URL; do
81+
echo "Downloading artifact: $NAME"
82+
curl -L \
83+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
84+
-o "$NAME.zip" "$URL"
85+
unzip "$NAME.zip" -d "artifacts/$NAME"
86+
rm "$NAME.zip"
87+
done <<< "$ARTS"
88+
- uses: maxim-lobanov/setup-xcode@v1
89+
with:
90+
xcode-version: latest-stable
91+
- name: Merge Result Bundles
92+
run: |
93+
# Dynamically find all .xcresult directories in artifacts
94+
XCBUNDLES=($(find artifacts -type d -name '*.xcresult'))
95+
if [ ${#XCBUNDLES[@]} -gt 1 ]; then
96+
xcrun xcresulttool merge "${XCBUNDLES[@]}" --output-path artifacts/ResultBundle.xcresult
97+
else
98+
# If there's only one bundle, just rename it as the merged output
99+
mv "${XCBUNDLES[0]}" artifacts/ResultBundle.xcresult
100+
fi
101+
- name: Cleanup Old Artifacts from GitHub
102+
run: |
103+
curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
104+
-H 'Accept: application/vnd.github+json' \
105+
"https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts" \
106+
| jq -r '.artifacts[] | select(.name | endswith(".xcresult")) | .id' \
107+
| while read artifact_id; do
108+
echo "Deleting artifact ID: $artifact_id"
109+
curl -X DELETE -s \
110+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
111+
-H 'Accept: application/vnd.github+json' \
112+
"https://api.github.com/repos/${{ github.repository }}/actions/artifacts/$artifact_id"
113+
done
114+
- name: Re-upload Merged Result
115+
uses: actions/upload-artifact@v4
116+
with:
117+
name: ResultBundle.xcresult
118+
path: artifacts/ResultBundle.xcresult
119119

120120
coverage:
121121
runs-on: macos-latest
122122
needs: merge
123123
steps:
124-
- uses: actions/checkout@v3
125-
with:
126-
fetch-depth: 0
127-
- name: Download Merged Artifact
128-
uses: actions/download-artifact@v4
129-
with:
130-
name: ResultBundle.xcresult
131-
path: artifacts/ResultBundle.xcresult
132-
- uses: maxim-lobanov/setup-xcode@v1
133-
with:
134-
xcode-version: latest-stable
135-
- uses: slidoapp/[email protected]
136-
with:
137-
path: artifacts/ResultBundle.xcresult
138-
show-passed-tests: false
139-
upload-bundles: never
140-
- name: Install Dependencies
141-
run: |
142-
brew install --formula xcresultparser
143-
- name: Convert Merged Result to Coverage
144-
run: |
145-
xcresultparser \
146-
--output-format cobertura \
147-
artifacts/ResultBundle.xcresult > artifacts/coverage.xml
148-
- name: Upload Coverage to Codecov
149-
uses: codecov/codecov-action@v5
150-
with:
151-
files: artifacts/coverage.xml
152-
token: ${{ secrets.CODECOV_TOKEN }}
153-
flags: all_tests
154-
fail_ci_if_error: true
124+
- uses: actions/checkout@v3
125+
with:
126+
fetch-depth: 0
127+
- name: Download Merged Artifact
128+
uses: actions/download-artifact@v4
129+
with:
130+
name: ResultBundle.xcresult
131+
path: artifacts/ResultBundle.xcresult
132+
- uses: maxim-lobanov/setup-xcode@v1
133+
with:
134+
xcode-version: latest-stable
135+
- uses: slidoapp/[email protected]
136+
with:
137+
path: artifacts/ResultBundle.xcresult
138+
show-passed-tests: false
139+
upload-bundles: never
140+
- name: Install Dependencies
141+
run: |
142+
brew install --formula xcresultparser
143+
- name: Convert Merged Result to Coverage
144+
run: |
145+
xcresultparser \
146+
--output-format cobertura \
147+
artifacts/ResultBundle.xcresult > artifacts/coverage.xml
148+
- name: Upload Coverage to Codecov
149+
uses: codecov/codecov-action@v5
150+
with:
151+
files: artifacts/coverage.xml
152+
token: ${{ secrets.CODECOV_TOKEN }}
153+
flags: all_tests
154+
fail_ci_if_error: true

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# mpvx
22

3-
[![SwiftLint](https://github.com/HackingGate/mpvx/actions/workflows/swiftlint.yml/badge.svg)](https://github.com/HackingGate/mpvx/actions/workflows/swiftlint.yml)
3+
[![Lint](https://github.com/HackingGate/mpvx/actions/workflows/lint.yml/badge.svg)](https://github.com/HackingGate/mpvx/actions/workflows/lint.yml)
44
[![Build and Test](https://github.com/HackingGate/mpvx/actions/workflows/test-and-coverage.yml/badge.svg)](https://github.com/HackingGate/mpvx/actions/workflows/test-and-coverage.yml)
55
[![codecov](https://codecov.io/gh/HackingGate/mpvx/graph/badge.svg?token=TVGJ0H9CTZ)](https://codecov.io/gh/HackingGate/mpvx)
66
[![Release](https://github.com/HackingGate/mpvx/workflows/Release/badge.svg)](https://github.com/HackingGate/mpvx/releases)

lefthook.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ pre-commit:
22
parallel: true
33
commands:
44
setup:
5-
run: swiftlint --fix --strict
5+
run: |
6+
npx shfmt -w .
7+
npx prettier --write "**/*.{yml,md,json}"
8+
swiftlint --fix --strict
9+
610
post-commit:
711
parallel: true
812
commands:

0 commit comments

Comments
 (0)