Skip to content

Commit

Permalink
Merge pull request #66 from platformsh/local
Browse files Browse the repository at this point in the history
Local, workflow, and design improvements
  • Loading branch information
chadwcarlson authored Nov 1, 2023
2 parents 77633dc + d9b80fc commit 6b5aeb1
Show file tree
Hide file tree
Showing 17 changed files with 437 additions and 213 deletions.
50 changes: 32 additions & 18 deletions .github/workflows/project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ jobs:
- name: "[setup_repo] 1. Clone repository into runner."
run: |
echo "::notice::Cloning repo copy into runner."
git clone -b $DEFAULT_BRANCH \
https://github.com/$PROJECT_REPO.git \
$PROJECT_LOCALDIR
cmd=$(cat frontend/src/commands.json | jq -r ".first_deploy.test.clone")
eval "$cmd"
- name: "[setup_repo] 2. Setup runner Git user."
working-directory: ${{ env.PROJECT_LOCALDIR }}
run: |
Expand Down Expand Up @@ -186,6 +185,8 @@ jobs:
echo "::notice::First push to project."
# @todo: Push through Git, not the CLI, so the exit doesn't break the workflow.
git push --force upsun $DEFAULT_BRANCH
cmd=$(cat frontend/src/commands.json | jq -r ".first_deploy.test.push")
eval "$cmd"
# upsun push -f -y
- name: "[first_deploy] 2. Test: The first deploy activity should complete."
working-directory: ${{ env.PROJECT_LOCALDIR }}
Expand All @@ -201,7 +202,8 @@ jobs:
- name: "[init_resources] 1. Set initial resources."
working-directory: ${{ env.PROJECT_LOCALDIR }}
run: |
upsun resources:set --size '*:0.1' -y
cmd=$(cat frontend/src/commands.json | jq -r ".first_deploy.user.resources_set")
eval "$cmd"
- name: "[init_resources] 2. Test: The update environment resources activity should complete."
working-directory: ${{ env.PROJECT_LOCALDIR }}
run: |
Expand All @@ -214,28 +216,36 @@ jobs:
working-directory: ${{ env.PROJECT_LOCALDIR }}
run: |
EXPECTED_STATUS="200"
PROD_URL_FRONTEND=$(upsun url --primary --pipe)
cmd=$(cat frontend/src/commands.json | jq -r ".first_deploy.user.get_url")
eval "$cmd"
PROD_URL_FRONTEND=$(eval "$cmd --pipe")
./utils/tests/url_status.sh $PROD_URL_FRONTEND $EXPECTED_STATUS "production frontend deployment (init_resources)"
- name: "[init_resources] 5. Test: Updating environment resources should result in a 200 on the backend production app."
working-directory: ${{ env.PROJECT_LOCALDIR }}
run: |
EXPECTED_STATUS="200"
PROD_URL_FRONTEND=$(upsun url --primary --pipe)
cmd=$(cat frontend/src/commands.json | jq -r ".first_deploy.user.get_url")
eval "$cmd"
PROD_URL_FRONTEND=$(eval "$cmd --pipe")
PROD_URL_BACKEND=$PROD_URL_FRONTEND$BACKEND_PATH
./utils/tests/url_status.sh $PROD_URL_BACKEND $EXPECTED_STATUS "production backend deployment (init_resources)"
- name: "[init_resources] 6. Test: endpoint data (session_storage)"
working-directory: ${{ env.PROJECT_LOCALDIR }}
run: |
EXPECTED="file"
PROD_URL_FRONTEND=$(upsun url --primary --pipe)
cmd=$(cat frontend/src/commands.json | jq -r ".first_deploy.user.get_url")
eval "$cmd"
PROD_URL_FRONTEND=$(eval "$cmd --pipe")
PROD_URL_BACKEND=$PROD_URL_FRONTEND$BACKEND_PATH
RESULT=$(curl -s $PROD_URL_BACKEND | jq -r '.session_storage')
./$TEST_PATH/compare_strings.sh "$RESULT" "$EXPECTED" "PROD Backend data session_storage"
- name: "[init_resources] 7. Test: endpoint data (environment_type)"
working-directory: ${{ env.PROJECT_LOCALDIR }}
run: |
EXPECTED="production"
PROD_URL_FRONTEND=$(upsun url --primary --pipe)
cmd=$(cat frontend/src/commands.json | jq -r ".first_deploy.user.get_url")
eval "$cmd"
PROD_URL_FRONTEND=$(eval "$cmd --pipe")
PROD_URL_BACKEND=$PROD_URL_FRONTEND$BACKEND_PATH
RESULT=$(curl -s $PROD_URL_BACKEND | jq -r '.type')
./$TEST_PATH/compare_strings.sh "$RESULT" "$EXPECTED" "PROD Backend data environment_type"
Expand Down Expand Up @@ -295,10 +305,11 @@ jobs:
working-directory: ${{ env.PROJECT_LOCALDIR }}
run: |
./utils/uncomment.sh .upsun/config.yaml add_service
git commit -am "Create a redis service."
cmd=$(cat frontend/src/commands.json | jq -r ".redis.user.commit")
eval "$cmd"
# Push through Git, not the CLI, so the exit doesn't break the workflow.
git push --force upsun $STAGING_BRANCH
# upsun push -f -y
cmd=$(cat frontend/src/commands.json | jq -r ".redis.test.push")
eval "$cmd"
- name: "[add_service] 2. Test: The add_service activity should complete."
working-directory: ${{ env.PROJECT_LOCALDIR }}
run: |
Expand All @@ -314,6 +325,8 @@ jobs:
working-directory: ${{ env.PROJECT_LOCALDIR }}
run: |
upsun resources:set --size redis_persistent:0.1 --disk redis_persistent:512
cmd=$(cat frontend/src/commands.json | jq -r ".redis.user.resources_set")
eval "$cmd"
- name: "[add_service_resources] 2. Test: The add_service_resources activity should complete."
working-directory: ${{ env.PROJECT_LOCALDIR }}
run: |
Expand Down Expand Up @@ -357,11 +370,8 @@ jobs:
- name: "[merge] 1. Merge staging into production."
working-directory: ${{ env.PROJECT_LOCALDIR }}
run: |
git checkout $DEFAULT_BRANCH
git merge $STAGING_BRANCH
# Push through Git, not the CLI, so the exit doesn't break the workflow.
git push --force upsun $DEFAULT_BRANCH
# upsun merge staging -y
cmd=$(cat frontend/src/commands.json | jq -r ".merge_production.test.merge")
eval "$cmd"
- name: "[merge] 2. Test: The merge activity should complete."
working-directory: ${{ env.PROJECT_LOCALDIR }}
run: |
Expand All @@ -376,7 +386,9 @@ jobs:
- name: "[prod_service_resources] 1. Set Redis' resources on production."
working-directory: ${{ env.PROJECT_LOCALDIR }}
run: |
upsun resources:set --size redis_persistent:0.1 --disk redis_persistent:512 -e $DEFAULT_BRANCH
# upsun resources:set --size redis_persistent:0.1 --disk redis_persistent:512 -e $DEFAULT_BRANCH
cmd=$(cat frontend/src/commands.json | jq -r ".merge_production.test.resources_set")
eval "$cmd"
- name: "[prod_service_resources] 2. Test: The update environment resources activity should complete."
working-directory: ${{ env.PROJECT_LOCALDIR }}
run: |
Expand Down Expand Up @@ -420,4 +432,6 @@ jobs:
- name: "[cleanup] 1. Delete project."
working-directory: ${{ env.PROJECT_LOCALDIR }}
run: |
upsun project:delete -y
# upsun project:delete -y
cmd=$(cat frontend/src/commands.json | jq -r ".complete.user.delete_project")
eval "$cmd -y"
10 changes: 2 additions & 8 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,14 @@ jobs:
export CI=true
npm install cross-env npm-run-all -g
npm install
npm run test
npm run test:frontend
################################################################################################
# C. Ensure no vulnerabilities.
- name: "5. Test: there should be no Python vulnerabilities."
run: |
echo "::notice::Checking for vulnerabilities in backend Python app dependencies."
cd backend
python3 -m venv env
source env/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
# pip-audit will exit 1 if vulnerabilities found (https://github.com/pypa/pip-audit#exit-codes)
pip-audit -r requirements.txt
npm run test:backend
- name: "6. Test: there should be no HIGH Node.js vulnerabilities."
run: |
echo "::notice::Checking for high vulnerabilities in frontend Node.js app dependencies."
Expand Down
8 changes: 8 additions & 0 deletions backend/scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

python3 -m venv env
source env/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
# pip-audit will exit 1 if vulnerabilities found (https://github.com/pypa/pip-audit#exit-codes)
pip-audit -r requirements.txt
Loading

0 comments on commit 6b5aeb1

Please sign in to comment.