Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Lind111 committed Mar 20, 2024
1 parent 1254d3c commit 6eab8e7
Show file tree
Hide file tree
Showing 14 changed files with 3,587 additions and 862 deletions.

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions .github/workflows/approval-validator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Validate Application Approval

on:
pull_request:
types:
- opened
- synchronize

jobs:
validate-approval:
runs-on: ubuntu-latest
env:
BACKEND_URL: https://fp-core-prod.dp04sa0tdc6pk.us-east-1.cs.amazonlightsail.com
steps:
- name: Call Backend to Validate Application Approval
id: validate
run: |
USER_HANDLE="${{ github.actor }}"
REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2)
OWNER_NAME="${{ github.repository_owner }}"
PR_NUMBER="${{ github.event.pull_request.number }}"
echo "Calling backend to validate with pr_number: $PR_NUMBER, user_handle: $USER_HANDLE, repo: $REPO_NAME, and owner: $OWNER_NAME"
RESPONSE=$(curl --header "Content-Type: application/json" \
--request POST \
--data '{"pr_number": "'$PR_NUMBER'", "user_handle": "'$USER_HANDLE'", "repo": "'$REPO_NAME'", "owner": "'$OWNER_NAME'"}' \
"${BACKEND_URL}/application/approval/validate")
echo "Response from validation: $RESPONSE"
if [ "$RESPONSE" != "true" ]; then
echo "Error: Validation returned false"
exit 1
fi
- name: Validation Success
if: steps.validate.outcome == 'success'
run: echo "Validation successful!"
47 changes: 47 additions & 0 deletions .github/workflows/automerge-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This workflow will automerge a pull request when some conditions are met.
# Use Cases:
# - When an application (new or refill) is proposed and approved by two notaries.
# · application.info.application_lifecycle.state == 'Confirmed'
# · application.info.application_lifecycle.first_allocation_time != ''
# - When an application has reached its total datacap and the SSA bot marked it as inactive
# · application.info.application_lifecycle.is_active == false
name: Automerge Pull Request

on:
pull_request:
types:
- opened
- synchronize
- reopened
branches:
- main

jobs:
automerge-pr:
runs-on: ubuntu-latest
env:
BACKEND_URL: https://fp-core-prod.dp04sa0tdc6pk.us-east-1.cs.amazonlightsail.com
steps:
- name: Call Backend to Validate Automerge Request
id: validate
run: |
USER_HANDLE="${{ github.actor }}"
REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2)
OWNER_NAME="${{ github.repository_owner }}"
PR_NUMBER="${{ github.event.pull_request.number }}"
echo "Calling backend to validate automerge with pr_number: $PR_NUMBER, user_handle: $USER_HANDLE, repo: $REPO_NAME, and owner: $OWNER_NAME"
RESPONSE=$(curl --header "Content-Type: application/json" \
--request POST \
--data '{"pr_number": "'$PR_NUMBER'", "user_handle": "'$USER_HANDLE'", "repo": "'$REPO_NAME'", "owner": "'$OWNER_NAME'"}' \
"${BACKEND_URL}/application/merge/validate")
echo "Response from validation: $RESPONSE"
if [ "$RESPONSE" != "true" ]; then
echo "Error: Validation returned false"
exit 1
fi
- name: Validation Success
if: steps.validate.outcome == 'success'
run: echo "Validation successful!"
18 changes: 18 additions & 0 deletions .github/workflows/close-merged-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: delete branch on close pr
on:
pull_request:
types: [closed]

jobs:
delete-branch:
runs-on: ubuntu-latest
env:
BACKEND_URL: https://fp-core-prod.dp04sa0tdc6pk.us-east-1.cs.amazonlightsail.com
steps:
- name: Delete branch
run: |
REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2)
BRANCH_NAME=${{ github.head_ref }}
curl -X POST "${BACKEND_URL}/application/branch/delete" \
-H "Content-Type: application/json" \
-d '{"owner": "'${{ github.repository_owner }}'", "repo": "'$REPO_NAME'", "branch_name": "'$BRANCH_NAME'"}'
49 changes: 49 additions & 0 deletions .github/workflows/flow-validator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This workflow will validate if an application flow is correct
# Use Cases:
# - When an application is in "submitted state"
# · application.info.application_lifecycle.validated_by must be empty
# · application.info.application_lifecycle.validated_at must be empty
# · application.info.application_lifecycle.current_allocation_id must be empty
# · application.info.datacap_allocations array must be empty
# - When an aplication is in some other state
# · actor must be the Filplus Bot
name: Flow Validator

on:
pull_request:
types:
- opened
- synchronize
- reopened
branches:
- main

jobs:
validate-flow:
runs-on: ubuntu-latest
env:
BACKEND_URL: https://fp-core-prod.dp04sa0tdc6pk.us-east-1.cs.amazonlightsail.com
steps:
- name: Call Backend to Validate Application Flow
id: validate
run: |
USER_HANDLE="${{ github.actor }}"
REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2)
OWNER_NAME="${{ github.repository_owner }}"
PR_NUMBER="${{ github.event.pull_request.number }}"
echo "Calling backend to validate with pr_number: $PR_NUMBER, user_handle: $USER_HANDLE, repo: $REPO_NAME, and owner: $OWNER_NAME"
RESPONSE=$(curl --header "Content-Type: application/json" \
--request POST \
--data '{"pr_number": "'$PR_NUMBER'", "user_handle": "'$USER_HANDLE'", "repo": "'$REPO_NAME'", "owner": "'$OWNER_NAME'"}' \
"${BACKEND_URL}/application/flow/validate")
echo "Response from validation: $RESPONSE"
if [ "$RESPONSE" != "true" ]; then
echo "Error: Validation returned false"
exit 1
fi
- name: Validation Success
if: steps.validate.outcome == 'success'
run: echo "Validation successful!"
25 changes: 25 additions & 0 deletions .github/workflows/issue-to-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Convert Issue To Pull Request

on:
issues:
types:
- opened

jobs:
convert-issue-to-pr:
runs-on: ubuntu-latest
env:
BACKEND_URL: https://fp-core-prod.dp04sa0tdc6pk.us-east-1.cs.amazonlightsail.com
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Convert Issue To PR
run: |
REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2)
echo "Converting Issue To PR with repo: $REPO_NAME"
echo "Issue number: ${{ github.event.issue.number }}"
curl --header "Content-Type: application/json" \
--request POST \
--data '{"issue_number": "'${{ github.event.issue.number }}'", "repo": "'$REPO_NAME'", "owner": "'${{ github.repository_owner }}'"}' \
"${BACKEND_URL}/application"
53 changes: 53 additions & 0 deletions .github/workflows/json-validator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Json Structure Validator

on:
pull_request:
types:
- opened
- synchronize
- reopened
branches:
- main
paths:
- '**/*.json'

jobs:
validate_json:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install AJV CLI
run: npm install -g ajv-cli

- name: Validate JSON
run: |
echo "Searching for JSON files..."
if [ "${{ github.event_name }}" == "pull_request" ]; then
FILE_TO_VALIDATE=$(git diff --name-only HEAD^1 HEAD | grep '\.json$' | head -n 1)
else
FILE_TO_VALIDATE=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep '\.json$' | head -n 1)
fi
echo "$FILE_TO_VALIDATE"
if [ -z "$FILE_TO_VALIDATE" ]; then
echo "No JSON files found for validation."
exit 0
fi
echo "Validating JSON file..."
if [ -f "$FILE_TO_VALIDATE" ]; then
echo "Validating $FILE_TO_VALIDATE..."
ajv validate -s validationSchema.json -d "$FILE_TO_VALIDATE" || exit 1
else
echo "$FILE_TO_VALIDATE not found. Skipping..."
fi
echo "Validation complete."
37 changes: 37 additions & 0 deletions .github/workflows/proposal-validator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Validate Application Proposal

on:
pull_request:
types:
- opened
- synchronize

jobs:
validate-proposal:
runs-on: ubuntu-latest
env:
BACKEND_URL: https://fp-core-prod.dp04sa0tdc6pk.us-east-1.cs.amazonlightsail.com
steps:
- name: Call Backend to Validate Application Proposal
id: validate
run: |
USER_HANDLE="${{ github.actor }}"
REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2)
OWNER_NAME="${{ github.repository_owner }}"
PR_NUMBER="${{ github.event.pull_request.number }}"
echo "Calling backend to validate with pr_number: $PR_NUMBER, user_handle: $USER_HANDLE, repo: $REPO_NAME, and owner: $OWNER_NAME"
RESPONSE=$(curl --header "Content-Type: application/json" \
--request POST \
--data '{"pr_number": "'$PR_NUMBER'", "user_handle": "'$USER_HANDLE'", "repo": "'$REPO_NAME'", "owner": "'$OWNER_NAME'"}' \
"${BACKEND_URL}/application/proposal/validate")
echo "Response from validation: $RESPONSE"
if [ "$RESPONSE" != "true" ]; then
echo "Error: Validation returned false"
exit 1
fi
- name: Validation Success
if: steps.validate.outcome == 'success'
run: echo "Validation successful!"
20 changes: 20 additions & 0 deletions .github/workflows/renew-application-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Renew Cache

on:
workflow_dispatch:
schedule:
# Schedule to run at 1 AM every day
- cron: '0 1 * * *'

jobs:
renew_cache:
runs-on: ubuntu-latest
env:
BACKEND_URL: https://fp-core-prod.dp04sa0tdc6pk.us-east-1.cs.amazonlightsail.com
steps:
- name: Renew Application Cache
run: |
REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2)
curl -X POST "${BACKEND_URL}/application/cache/renewal" \
-H "Content-Type: application/json" \
-d '{"owner": "'${{ github.repository_owner }}'", "repo": "'$REPO_NAME'"}'
37 changes: 37 additions & 0 deletions .github/workflows/trigger-validator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Validate Application Trigger

on:
pull_request:
types:
- opened
- synchronize

jobs:
validate-trigger:
runs-on: ubuntu-latest
env:
BACKEND_URL: https://fp-core-prod.dp04sa0tdc6pk.us-east-1.cs.amazonlightsail.com
steps:
- name: Call Backend to Validate Application Trigger
id: validate
run: |
USER_HANDLE="${{ github.actor }}"
REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2)
OWNER_NAME="${{ github.repository_owner }}"
PR_NUMBER="${{ github.event.pull_request.number }}"
echo "Calling backend to validate with pr_number: $PR_NUMBER, user_handle: $USER_HANDLE, repo: $REPO_NAME, and owner: $OWNER_NAME"
RESPONSE=$(curl --header "Content-Type: application/json" \
--request POST \
--data '{"pr_number": "'$PR_NUMBER'", "user_handle": "'$USER_HANDLE'", "repo": "'$REPO_NAME'", "owner": "'$OWNER_NAME'"}' \
"${BACKEND_URL}/application/trigger/validate")
echo "Response from validation: $RESPONSE"
if [ "$RESPONSE" != "true" ]; then
echo "Error: Validation returned false"
exit 1
fi
- name: Validation Success
if: steps.validate.outcome == 'success'
run: echo "Validation successful!"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vscode
.env
Empty file added applications/invalid.md
Empty file.
14 changes: 14 additions & 0 deletions data/govteam.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"gov_team": [
"panges2",
"simonkim0515",
"dkkapur",
"kevzak",
"galen-mcandrew",
"raghavrmadya",
"Sunnyiscoming",
"clriesco",
"kokal33",
"AlexMCon"
]
}
Loading

0 comments on commit 6eab8e7

Please sign in to comment.