-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: alexmerlin <[email protected]>
- Loading branch information
1 parent
195077e
commit 66d48b9
Showing
3 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Run curl tester | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- 4.0 | ||
|
||
jobs: | ||
run-bash: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Make curl tester executable | ||
run: chmod +x ./test/tester.sh | ||
|
||
- name: Run curl tester | ||
run: ./test/tester.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
|
||
# Bootstrap | ||
|
||
OK='✅' | ||
KO='❌' | ||
|
||
if ! command -v curl > /dev/null 2>&1; then | ||
echo "$KO curl is not installed" | ||
exit 1 | ||
fi | ||
|
||
# Define globals | ||
|
||
body="" | ||
status_code=0 | ||
|
||
# Functions | ||
|
||
send_request() { | ||
response=$(curl -s -w "\n%{http_code}" $1) | ||
|
||
body=$(echo "$response" | sed '$d') | ||
status_code=$(echo "$response" | tail -n 1) | ||
} | ||
|
||
get() { | ||
send_request $1 | ||
} | ||
|
||
post() { | ||
send_request $1 | ||
} | ||
|
||
# Endpoints | ||
|
||
endpoint_home="https://api.dotkernel.net" | ||
|
||
# Tests | ||
|
||
get $endpoint_home | ||
|
||
if echo "$body" | grep -q '{"message":"Welcome to DotKernel API!" }'; then | ||
echo "$OK $endpoint_home: SUCCESS ($status_code)" | ||
else | ||
echo "$KO $endpoint_home: FAILED ($status_code)" | ||
exit 1 | ||
fi |