Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge main into dev #424

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b6afce2
Add workflow
ntampakas Feb 8, 2024
e7f358f
Add auxiliary scripts to spawn/configure/manage the ephemeral instance
ntampakas Feb 8, 2024
4a61913
Run prettier
ntampakas Feb 9, 2024
65136d9
ci: improve ci performance
baumstern Feb 10, 2024
1bd08a7
Merge pull request #382 from ntampakas/main
vplasencia Feb 20, 2024
dc3a72f
Merge pull request #383 from baumstern/chore/ci-cache
ntampakas Feb 20, 2024
afe0f67
docs: add Bandada repository link to the API docs (closes #403)
intldds Feb 21, 2024
8853100
docs: update configUI
intldds Feb 22, 2024
61b344a
Merge pull request #405 from intldds/feat/addRepoLink
vplasencia Feb 22, 2024
7ebce43
fix: fix typos
rex4539 Feb 25, 2024
7641946
fix(dashboard): hide danger zone & api key sections for non-admins
ryanpwaldon Feb 29, 2024
db76f5a
Merge pull request #413 from ryanpwaldon/fix/hide-api-key-and-danger-…
vplasencia Feb 29, 2024
fbe9c1a
Merge pull request #409 from rex4539/typos
vplasencia Feb 29, 2024
e1e1c86
fix(dashboard): hide member edit actions for non-admins
ryanpwaldon Mar 1, 2024
1a8973c
chore: prettify
ryanpwaldon Mar 1, 2024
f4095e1
Updated the ApiSdk constructor documentation
Ayoseun Mar 4, 2024
7607614
Removed axios config comment example
Ayoseun Mar 4, 2024
89d16b8
Merge pull request #416 from ryanpwaldon/fix/hide-admin-features-for-…
vplasencia Mar 5, 2024
dc667e8
fix broken links
omahs Mar 5, 2024
336c810
Merge pull request #422 from omahs/patch-3
vplasencia Mar 5, 2024
228abfa
Corrected text casing
Ayoseun Mar 5, 2024
8d2a80b
Merge pull request #420 from Ayoseun/main
vplasencia Mar 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/scripts/cloud-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh

set -eux
trap 'poweroff' TERM EXIT INT

Repo=$(curl http://169.254.169.254/latest/meta-data/tags/instance/Repo)
Branch=$(curl http://169.254.169.254/latest/meta-data/tags/instance/Branch)

Local_IP=$(curl http://169.254.169.254/latest/meta-data/local-ipv4)

# Install pkgs
apt-get update
apt-get install -y net-tools
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
usermod -aG docker ubuntu

su -P ubuntu -c "git clone -b $Branch --single-branch https://github.com/ntampakas/$Repo.git /home/ubuntu/$Repo"
su -P ubuntu -c "cp /home/ubuntu/$Repo/apps/api/.env.example /home/ubuntu/$Repo/apps/api/.env"
su -P ubuntu -c "sed -i 's/\(DB_TYPE=\).*/\1postgres/' /home/ubuntu/$Repo/apps/api/.env"
su -P ubuntu -c "sed -i 's/\(DB_URL=\).*/\1postgres:\/\/root:helloworld\@postgres:5432\/bandada/' /home/ubuntu/$Repo/apps/api/.env"

su -P ubuntu -c "rm /home/ubuntu/$Repo/apps/{client,dashboard}/.env.production /home/ubuntu/$Repo/apps/{client,dashboard}/.env.staging"
su -P ubuntu -c "sed -i 's/localhost/$Local_IP/g' /home/ubuntu/$Repo/apps/{client,dashboard}/.env.local"

su -P ubuntu -c "cd /home/ubuntu/$Repo ; docker compose up -d"

sleep 6h
16 changes: 16 additions & 0 deletions .github/scripts/get_ip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

set -eux

TRIGGER=$1
ACTOR=$2
VPC="vpc-07d12b28fd72d152e"

# Stop here in schedule
[ ! $TRIGGER = "maintenance" ] || exit 0

sleep 10

EC2_IP=$(aws ec2 describe-instances --filters "Name=instance-state-name,Values=[running]" "Name=tag:Name,Values='bandada-ephemeral-$ACTOR-*'" "Name=network-interface.vpc-id,Values=[$VPC]" --query "Reservations[*].Instances[*].[NetworkInterfaces[*].[PrivateIpAddress]]" --output text)

echo "URL: http://$EC2_IP:3001"
47 changes: 47 additions & 0 deletions .github/scripts/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/sh

set -eux

TRIGGER=$1
BRANCH=$2
ACTOR=$3
SHA=$4
AMI="ami-04e601abe3e1a910f"
SG="sg-04d8c2eb4beca2de9"
SUBNET="subnet-066cf21c696ef55c8"
VPC="vpc-07d12b28fd72d152e"

# Kill old instances
CURRENT_TIME_EPOCH=$(date -d `date -Is` +"%s")
EC2=$(aws ec2 describe-instances --filters "Name=instance-state-name,Values=[running]" "Name=tag:Name,Values='bandada-ephemeral-*'" "Name=network-interface.vpc-id,Values=[$VPC]" --query "Reservations[*].Instances[*].InstanceId" --output text)
for i in $EC2; do
EC2_LAUNCH_TIME=$(aws ec2 describe-instances --instance-ids $i --query 'Reservations[*].Instances[*].LaunchTime' --output text)
LAUNCH_TIME_EPOCH=$(date -d $EC2_LAUNCH_TIME +"%s")
diff=$(expr $CURRENT_TIME_EPOCH - $LAUNCH_TIME_EPOCH)

if [ $diff -gt 21600 ]; then
aws ec2 terminate-instances --instance-ids $i
fi
done

# Stop here in schedule
[ ! $TRIGGER = "maintenance" ] || exit 0

# Check if actor ec2 exists
ACTOR_EC2=$(aws ec2 describe-instances --filters "Name=instance-state-name,Values=[running]" "Name=tag:Name,Values='bandada-ephemeral-$ACTOR-*'" "Name=network-interface.vpc-id,Values=[$VPC]" --query "Reservations[*].Instances[*].InstanceId" --output text)

[ -z $ACTOR_EC2 ] || aws ec2 terminate-instances --instance-ids $ACTOR_EC2

# Launch new instance
aws ec2 run-instances \
--user-data "file://.github/scripts/cloud-init.sh" \
--image-id $AMI \
--count 1 \
--instance-type t3a.large \
--key-name bandada \
--security-group-ids $SG \
--subnet-id $SUBNET \
--block-device-mappings "[{\"DeviceName\":\"/dev/sda1\",\"Ebs\":{\"VolumeSize\":32,\"DeleteOnTermination\":true}}]" \
--instance-initiated-shutdown-behavior terminate \
--tag-specification "ResourceType=instance,Tags=[{Key=Name,Value="bandada-ephemeral-$ACTOR-$SHA"},{Key=Repo,Value="bandada"},{Key=Branch,Value="$BRANCH"}]" \
--metadata-options "InstanceMetadataTags=enabled"
30 changes: 6 additions & 24 deletions .github/workflows/coverall.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ on:
branches:
- main

env:
DEFAULT_NETWORK: localhost

jobs:
test:
runs-on: ubuntu-latest
Expand All @@ -18,37 +15,22 @@ jobs:
- contracts

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.x
cache: "yarn"

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"

- name: Restore yarn cache
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Install dependencies
- name: Build monorepo
run: yarn

- name: Build libraries
run: yarn workspaces foreach --no-private run build

- name: Test code
run: yarn test:${{ matrix.tests }}:coverage

- name: Coveralls
uses: coverallsapp/github-action@master
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: run-${{ matrix.tests }}
Expand All @@ -60,7 +42,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
fi

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
persist-credentials: false

Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/ephemeral.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Ephemeral
on:
schedule:
- cron: "0 */6 * * *"
workflow_dispatch:
inputs:
action:
description: "Action"
required: true
default: "spawn"
type: choice
options:
- spawn

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

jobs:
deploy:
timeout-minutes: 5
runs-on: ubuntu-latest
env:
DATA: ${{ github.event.inputs.action || 'maintenance' }}
permissions:
id-token: write
contents: read

steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::490752553772:role/bandada-ephemeral-deploy-slc
role-duration-seconds: 900
aws-region: eu-central-1

- name: Launch instance
run: |
.github/scripts/run.sh ${{ env.DATA }} $GITHUB_REF_NAME $GITHUB_TRIGGERING_ACTOR $GITHUB_SHA

- name: Instance IP
run: |
.github/scripts/get_ip.sh ${{ env.DATA }} $GITHUB_TRIGGERING_ACTOR
2 changes: 1 addition & 1 deletion .github/workflows/postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
fi

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
persist-credentials: false

Expand Down
22 changes: 6 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,19 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.x
cache: "yarn"

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"

- name: Restore yarn cache
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Install dependencies
- name: Build monorepo
run: yarn

- run: yarn version:release
Expand Down
23 changes: 4 additions & 19 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,17 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.x
cache: "yarn"

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"

- name: Restore yarn cache
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Install dependencies
- name: Build monorepo
run: yarn

- name: Build
run: yarn build

- name: Run Prettier
run: yarn prettier

Expand Down
26 changes: 4 additions & 22 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,21 @@ on:
branches:
- main

env:
DEFAULT_NETWORK: localhost

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.x
cache: "yarn"

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"

- name: Restore yarn cache
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Install dependencies
- name: Build monorepo
run: yarn

- name: Build libraries
run: yarn workspaces foreach --no-private run build

- name: Test code
run: yarn test
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Please see the latest [documentation](https://pse-team.notion.site/Bandada-82d0d

## 🔧 Configuration

### Prerequisities
### Prerequisites

- [NodeJS](https://nodejs.org/en) >= v18.17.0

Expand Down Expand Up @@ -236,7 +236,7 @@ yarn test

## 🐳 Running in Docker

### Prerequisities
### Prerequisites

- [Docker](https://www.docker.com/) >= 4.26.1
- [docker-compose](https://docs.docker.com/compose/) >= 2.24.2
Expand Down
Loading
Loading