-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HMS-5287: Add playwright and github action to backend (#956)
* HMS-5287: Add playwright and github action to backend * Update synax on content-sources-action * Add repo import so redhat repo navigation doesn't fail * Update job to support 1 redhat repo * Updated as per PR Review * Remove comments in playwright config * Update readme to have a few notes on playwright * Kill unused db-migrate-seed with fire * Add script * Update documentation * Readme update * Updates as per review * fix broken link * Don't use feature service for testing. * Update script to blank out server * Update error handling in owner.go * Update example config to allow all-features by default * Get rid if DS_store
- Loading branch information
1 parent
2095633
commit cb90349
Showing
28 changed files
with
1,426 additions
and
81 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/bin/bash | ||
|
||
# Check if the search string is provided as an argument | ||
if [ -z "$1" ]; then | ||
echo "Usage: $0 <search-string>" | ||
exit 1 | ||
fi | ||
|
||
# Variables | ||
REPO_URL="https://api.github.com/repos/content-services/content-sources-frontend" | ||
GIT_REPO_URL="https://github.com/content-services/content-sources-frontend.git" | ||
CLONE_DIR=content-sources-frontend | ||
TAG_NAME="#testwith" | ||
SEARCH_STRING="$1" | ||
|
||
# Check if the folder exists | ||
if [ -d "$CLONE_DIR" ]; then | ||
echo "Folder '$CLONE_DIR' exists. Removing it..." | ||
rm -rf "$CLONE_DIR" | ||
|
||
# Check if the removal was successful | ||
if [ ! -d "$CLONE_DIR" ]; then | ||
echo "Successfully removed the folder '$CLONE_DIR'." | ||
else | ||
echo "Failed to remove the folder '$CLONE_DIR'." | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# Create clone directory if it doesn't exist | ||
mkdir -p $CLONE_DIR | ||
|
||
# Fetch the list of open pull requests | ||
prs=$(curl -s "$REPO_URL/pulls") | ||
|
||
# Iterate through the list of PRs and clone the first matching PR | ||
found_pr=false | ||
|
||
while read -r pr; do | ||
# Extract PR title, body, and branch details | ||
pr_title=$(echo "$pr" | jq -r '.title') | ||
pr_body=$(echo "$pr" | jq -r '.body') | ||
pr_number=$(echo "$pr" | jq -r '.number') | ||
pr_branch=$(echo "$pr" | jq -r '.head.ref') | ||
pr_repo=$(echo "$pr" | jq -r '.head.repo.clone_url') | ||
|
||
# Check if PR title or body contains the search string | ||
if [[ "$pr_body" == *"$TAG_NAME"* ]] && [[ "$pr_body" == *"$SEARCH_STRING"* ]]; then | ||
echo "Cloning PR #$pr_number: $pr_title" | ||
git clone --branch $pr_branch $pr_repo $CLONE_DIR | ||
|
||
# Check if the clone was successful | ||
if [ $? -eq 0 ]; then | ||
found_pr=true | ||
echo "Successfully cloned PR #$pr_number into $CLONE_DIR" | ||
else | ||
echo "Failed to clone PR #$pr_number" | ||
exit 1 | ||
fi | ||
|
||
# Exit the loop after cloning the first matching PR | ||
break | ||
fi | ||
done < <(echo "$prs" | jq -c '.[]') | ||
|
||
# If no matching PR was found, clone the main branch | ||
if [ "$found_pr" == false ]; then | ||
echo "No PR title or description contains '$TAG_NAME $SEARCH_STRING'. Cloning the main branch." | ||
git clone --branch main $GIT_REPO_URL $CLONE_DIR | ||
|
||
# Check if the clone was successful | ||
if [ $? -eq 0 ]; then | ||
echo "Successfully cloned main branch into $CLONE_DIR" | ||
else | ||
echo "Failed to clone the main branch" | ||
exit 1 | ||
fi | ||
fi |
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,29 @@ | ||
#!/bin/bash | ||
|
||
# Function to check if the server is up | ||
is_server_up() { | ||
response=$(curl --write-out '%{http_code}' --silent --output /dev/null http://127.0.0.1:8000/ping) | ||
if [ "$response" -eq 200 ]; then | ||
return 0 | ||
else | ||
return 1 | ||
fi | ||
} | ||
|
||
# Wait for the server to be ready with a timeout | ||
echo "Waiting for backend to be ready..." | ||
timeout=180 # Timeout in seconds | ||
interval=1 # Check interval in seconds | ||
elapsed=0 | ||
|
||
until is_server_up; do | ||
printf "\r%d/%d seconds have elapsed until timeout..." "$elapsed" "$timeout" | ||
sleep $interval | ||
elapsed=$((elapsed + interval)) | ||
if [ $elapsed -ge $timeout ]; then | ||
echo -e "\nError: Timed out waiting for the backend server to be ready." | ||
exit 1 | ||
fi | ||
done | ||
|
||
echo -e "\nBackend server is up and running after $elapsed seconds" |
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 |
---|---|---|
|
@@ -4,17 +4,22 @@ on: | |
branches: | ||
- main | ||
paths-ignore: | ||
- '**.md' | ||
- "**.md" | ||
pull_request: | ||
paths-ignore: | ||
- '**.md' | ||
- "**.md" | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
openapidiff: | ||
name: Openapi diff | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-go@v2 | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: "1.23" | ||
- run: | | ||
|
@@ -28,7 +33,7 @@ jobs: | |
name: openapi validate | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v3 | ||
- uses: openapi-generators/openapitools-generator-action@v1 | ||
with: | ||
generator: python | ||
|
@@ -38,22 +43,23 @@ jobs: | |
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-go@v2 | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: "1.23" | ||
|
||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.61.0 | ||
skip-go-installation: true | ||
args: --timeout=5m | ||
|
||
checkmigrations: | ||
name: Check db migrations | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v3 | ||
- uses: tj-actions/changed-files@v41 | ||
id: files | ||
- run: | | ||
|
@@ -62,12 +68,12 @@ jobs: | |
migrations_latest=$(cat db/migrations.latest) | ||
num_files_added=${{ steps.files.outputs.added_files_count }} | ||
if [ "$num_files_added" -gt 0 ]; then | ||
if [ "$num_files_added" -gt 0 ]; then | ||
new_migrations_added=$(echo "${{ steps.files.outputs.added_files }}" | grep 'db/migrations' || true) | ||
if [ -n "$new_migrations_added" ]; then | ||
if echo "$new_migrations_added" | grep -q "$migrations_latest"; then | ||
echo "OK: Latest migration content (db/migrations.latest) reflects the timestamp of the latest migrations added." | ||
else | ||
else | ||
echo "Error: Latest migration content (db/migrations.latest) does NOT reflect the timestamp of the latest migrations added." | ||
echo "New migration files added: $new_migrations_added" | ||
echo "In db/migration.latest: $migrations_latest" | ||
|
@@ -96,8 +102,8 @@ jobs: | |
ports: | ||
- 5433:5432 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-go@v2 | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: "1.23" | ||
- name: unit tests | ||
|
@@ -116,10 +122,12 @@ jobs: | |
CLIENTS_CANDLEPIN_USERNAME: admin | ||
CLIENTS_CANDLEPIN_PASSWORD: admin | ||
CLIENTS_CANDLEPIN_DEVEL_ORG: true | ||
|
||
- name: Add hosts to /etc/hosts | ||
run: | | ||
# allows pulp container to talk to the host at this hostname | ||
sudo echo "172.17.0.1 pulp.content" | sudo tee -a /etc/hosts | ||
- name: start pulp | ||
uses: isbang/[email protected] | ||
with: | ||
|
@@ -166,6 +174,7 @@ jobs: | |
CLIENTS_CANDLEPIN_USERNAME: admin | ||
CLIENTS_CANDLEPIN_PASSWORD: admin | ||
CLIENTS_CANDLEPIN_DEVEL_ORG: true | ||
|
||
- name: db migration tests | ||
run: | | ||
make test-db-migrations | ||
|
Oops, something went wrong.