Skip to content

Commit 1c90238

Browse files
authored
Openapi script updates (#17)
- Upgrade OpenAPI scripts - Add Bats tests - Add new scripts: `run-actionlint.sh`, `script-format.sh` - Add Bats workflow - Format all scripts - Fix minor script errors - Update README
1 parent 703a524 commit 1c90238

40 files changed

Lines changed: 2875 additions & 384 deletions

.github/workflows/bats_tests.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Bats Tests
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}-bats-tests
13+
cancel-in-progress: true
14+
15+
jobs:
16+
actionlint:
17+
name: Validate GitHub Workflows (actionlint)
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout Repository
22+
uses: actions/checkout@v6
23+
with:
24+
persist-credentials: false
25+
26+
- name: Install actionlint
27+
run: |
28+
ACTIONLINT_VERSION="1.7.7"
29+
curl -sSfL "https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}/actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz" \
30+
| tar -xz
31+
sudo mv actionlint /usr/local/bin/actionlint
32+
actionlint -version
33+
34+
- name: Run Workflow Linter
35+
run: actionlint
36+
37+
shellcheck:
38+
name: Lint Shell Scripts (shellcheck)
39+
runs-on: ubuntu-latest
40+
41+
steps:
42+
- name: Checkout Repository
43+
uses: actions/checkout@v6
44+
with:
45+
persist-credentials: false
46+
47+
- name: Install shellcheck
48+
run: |
49+
sudo apt-get update -y
50+
sudo apt-get install -y shellcheck
51+
52+
- name: Run Shell Linter
53+
run: shellcheck scripts/*.sh
54+
55+
shfmt:
56+
name: Check Shell Formatting (shfmt)
57+
runs-on: ubuntu-latest
58+
59+
steps:
60+
- name: Checkout Repository
61+
uses: actions/checkout@v6
62+
with:
63+
persist-credentials: false
64+
65+
- name: Install shfmt
66+
run: |
67+
sudo apt-get update -y
68+
sudo apt-get install -y shfmt
69+
70+
- name: Run Shell Formatter Check
71+
run: git ls-files '*.sh' '*.bash' '*.bats' | xargs shfmt -d -i 4 -ci
72+
73+
bats:
74+
name: Run Shell Test Suite (bats)
75+
needs:
76+
- shellcheck
77+
- shfmt
78+
- actionlint
79+
runs-on: ${{ matrix.os }}
80+
strategy:
81+
fail-fast: false
82+
matrix:
83+
os:
84+
- ubuntu-latest
85+
- macos-latest
86+
87+
steps:
88+
- name: Checkout Repository
89+
uses: actions/checkout@v6
90+
with:
91+
persist-credentials: false
92+
93+
- name: Install bats (Linux)
94+
if: runner.os == 'Linux'
95+
run: |
96+
sudo apt-get update -y
97+
sudo apt-get install -y bats
98+
99+
- name: Install bats (macOS)
100+
if: runner.os == 'macOS'
101+
run: brew install bats-core
102+
103+
- name: Run bats Test Suite
104+
run: bats --recursive tests/bats

.github/workflows/extra_soundness.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ on:
1515
type: boolean
1616
description: "Boolean to enable run tests with .build cache."
1717
default: false
18+
tests_cache_enabled:
19+
type: boolean
20+
description: "Boolean to enable .build cache usage inside the run tests job."
21+
default: true
1822
run_tests_swift_versions:
1923
type: string
2024
description: "List of Swift versions to test with."
@@ -126,11 +130,13 @@ jobs:
126130
ssh-keyscan github.com >> ~/.ssh/known_hosts
127131
128132
- name: Install zstd
133+
if: ${{ inputs.tests_cache_enabled }}
129134
run: |
130135
sudo apt-get update -y
131136
sudo apt-get install -y zstd
132137
133138
- name: Restore .build
139+
if: ${{ inputs.tests_cache_enabled }}
134140
id: "restore-build"
135141
uses: actions/cache/restore@v4
136142
with:
@@ -142,11 +148,16 @@ jobs:
142148
run: swift build --build-tests
143149

144150
- name: Cache .build
145-
if: steps.restore-build.outputs.cache-hit != 'true'
151+
if: ${{ inputs.tests_cache_enabled && steps.restore-build.outputs.cache-hit != 'true' }}
146152
uses: actions/cache/save@v4
147153
with:
148154
path: .build
149155
key: "swiftpm-tests-build-${{ runner.os }}-${{ matrix.swift }}-${{ github.event.pull_request.base.sha || github.event.after }}"
150156

151157
- name: Run unit tests
152-
run: swift test --skip-build --parallel
158+
run: |
159+
if [ "${{ inputs.tests_cache_enabled }}" = "true" ]; then
160+
swift test --skip-build --parallel
161+
else
162+
swift test --parallel
163+
fi

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,16 @@ format:
6666
package:
6767
curl -s $(baseUrl)/check-swift-package.sh | bash
6868

69+
lint-shell:
70+
curl -s $(baseUrl)/script-format.sh | bash
71+
72+
format-shell:
73+
curl -s $(baseUrl)/script-format.sh | bash -s -- --fix
74+
75+
lint-workflows:
76+
curl -s $(baseUrl)/run-actionlint.sh | bash
77+
6978
check: symlinks language deps lint docc-warnings headers
79+
80+
test-bats:
81+
bats --recursive tests/bats

0 commit comments

Comments
 (0)