Skip to content

Commit

Permalink
Resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadranjbarz committed Sep 6, 2023
2 parents a686f29 + ea91acc commit 0092f5a
Show file tree
Hide file tree
Showing 76 changed files with 2,671 additions and 1,646 deletions.
98 changes: 98 additions & 0 deletions .github/workflows/develop-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: develop-pipeline

on:
push:
branches:
- develop
pull_request:
branches:
- develop
jobs:
test:
runs-on: ubuntu-latest
services:
# Label used to access the service container
redis:
# Docker Hub image
image: redis
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
postgres:
# Use this postgres image https://github.com/Giveth/postgres-givethio
image: ghcr.io/giveth/postgres-givethio:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: givethio
PGDATA: /var/lib/postgresql/data/pgdata
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5443:5432
steps:
- uses: actions/checkout@v1
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 18.17.1
- name: Install dependencies
run: npm ci
- name: Run tslint
run: npm run tslint
- name: Run build
run: npm run build
- name: Run migrations
run: npm run db:migrate:run:test
- name: Run tests
run: npm run test
env:
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
XDAI_NODE_HTTP_URL: ${{ secrets.XDAI_NODE_HTTP_URL }}
INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}
INFURA_ID: ${{ secrets.INFURA_ID }}
POLYGON_SCAN_API_KEY: ${{ secrets.POLYGON_SCAN_API_KEY }}
OPTIMISTIC_SCAN_API_KEY: ${{ secrets.OPTIMISTIC_SCAN_API_KEY }}
CELO_SCAN_API_KEY: ${{ secrets.CELO_SCAN_API_KEY }}
CELO_ALFAJORES_SCAN_API_KEY: ${{ secrets.CELO_ALFAJORES_SCAN_API_KEY }}

publish:
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Build image and push to GitHub Packages
uses: docker/build-push-action@v1
with:
username: ${{ github.actor }}
password: ${{ github.token }}
registry: ghcr.io
repository: giveth/impact-graph
add_git_labels: true
# Add branch name to docker image tag @see{@link https://github.com/docker/build-push-action/tree/releases/v1#tag_with_ref}
tag_with_ref: true
# Add commit hash to docker image tag @see{@link https://github.com/docker/build-push-action/tree/releases/v1#tag_with_sha}
tag_with_sha: true

deploy:
needs: publish
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Develop deploy
uses: garygrossgarten/[email protected]
with:
command: cd impact-graph && git checkout develop && git pull && docker-compose -f docker-compose-develop.yml pull && docker-compose -f docker-compose-develop.yml down && docker-compose -f docker-compose-develop.yml up -d && docker image prune -a --force;
host: ${{ secrets.DEVELOP_HOST }}
username: ${{ secrets.DEVELOP_USERNAME }}
privateKey: ${{ secrets.DEVELOP_PRIVATE_KEY}}
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
name: CI/CD

on: [push]
name: master-pipeline

on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -38,7 +43,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 16.14.2
node-version: 18.17.1
- name: Install dependencies
run: npm ci
- name: Run tslint
Expand All @@ -60,9 +65,9 @@ jobs:
CELO_ALFAJORES_SCAN_API_KEY: ${{ secrets.CELO_ALFAJORES_SCAN_API_KEY }}

publish:
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/staging'
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Check out the repo
uses: actions/checkout@v2
Expand All @@ -80,30 +85,11 @@ jobs:
tag_with_sha: true

deploy:
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master'|| github.ref == 'refs/heads/staging'
needs: publish
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Staging deploy
if: github.ref == 'refs/heads/staging'
uses: garygrossgarten/[email protected]
with:
command: cd impact-graph && git checkout staging && git pull && docker-compose -f docker-compose-staging.yml pull && docker-compose -f docker-compose-staging.yml down && docker-compose -f docker-compose-staging.yml up -d && docker image prune -a --force;
host: ${{ secrets.STAGING_HOST }}
username: ${{ secrets.STAGING_USERNAME }}
privateKey: ${{ secrets.STAGING_PRIVATE_KEY}}

- name: Develop deploy
if: github.ref == 'refs/heads/develop'
uses: garygrossgarten/[email protected]
with:
command: cd impact-graph && git checkout develop && git pull && docker-compose -f docker-compose-develop.yml pull && docker-compose -f docker-compose-develop.yml down && docker-compose -f docker-compose-develop.yml up -d && docker image prune -a --force;
host: ${{ secrets.DEVELOP_HOST }}
username: ${{ secrets.DEVELOP_USERNAME }}
privateKey: ${{ secrets.DEVELOP_PRIVATE_KEY}}

- name: Production deploy
if: github.ref == 'refs/heads/master'
uses: garygrossgarten/[email protected]
with:
command: cd impact-graph && git checkout master && git pull && docker-compose -f docker-compose-production.yml pull && docker-compose -f docker-compose-production.yml down && docker-compose -f docker-compose-production.yml up -d && docker image prune -a --force;
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/run-tests-on-pr.yml.bck
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: run tests on pull request

on:
workflow_dispatch:
pull_request:
branches:
- develop
- master
- staging
types:
- opened

jobs:
test:
runs-on: ubuntu-latest
services:
# Label used to access the service container
redis:
# Docker Hub image
image: redis
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
postgres:
# Use this postgres image https://github.com/Giveth/postgres-givethio
image: ghcr.io/giveth/postgres-givethio:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: givethio
PGDATA: /var/lib/postgresql/data/pgdata
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5443:5432
steps:
- uses: actions/checkout@v1
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 16.14.2
- name: Install dependencies
run: npm ci
- name: Run tslint
run: npm run tslint
- name: Run build
run: npm run build
- name: Run migrations
run: npm run db:migrate:run:test
- name: Run tests
run: npm run test
env:
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
XDAI_NODE_HTTP_URL: ${{ secrets.XDAI_NODE_HTTP_URL }}
INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}
INFURA_ID: ${{ secrets.INFURA_ID }}
POLYGON_SCAN_API_KEY: ${{ secrets.POLYGON_SCAN_API_KEY }}
OPTIMISTIC_SCAN_API_KEY: ${{ secrets.OPTIMISTIC_SCAN_API_KEY }}
CELO_SCAN_API_KEY: ${{ secrets.CELO_SCAN_API_KEY }}
CELO_ALFAJORES_SCAN_API_KEY: ${{ secrets.CELO_ALFAJORES_SCAN_API_KEY }}
140 changes: 140 additions & 0 deletions .github/workflows/staging-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: staging-pipeline

on:
push:
branches:
- staging
pull_request:
branches:
- staging

jobs:
test:
runs-on: ubuntu-latest
services:
# Label used to access the service container
redis:
# Docker Hub image
image: redis
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
postgres:
# Use this postgres image https://github.com/Giveth/postgres-givethio
image: ghcr.io/giveth/postgres-givethio:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: givethio
PGDATA: /var/lib/postgresql/data/pgdata
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5443:5432

steps:
- name: Checkout
uses: actions/checkout@v1
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_S3_REGION }}

- name: Download latest DB backup from S3
run: |
FILENAME=$(aws s3 ls ${{ secrets.AWS_S3_BUCKET_PATH_STAGING }}/ | sort | tail -n 1 | awk '{print $4}')
aws s3 cp ${{ secrets.AWS_S3_BUCKET_PATH_STAGING }}/$FILENAME /tmp/db_backup.zip
- name: Unzip DB backup
run: |
unzip /tmp/db_backup.zip -d /tmp
mv /tmp/backups/givethio-staging/*.sql /tmp/backups/givethio-staging/db_backup.sql
- name: Wait for PostgreSQL to become ready
run: |
for i in {1..10}
do
pg_isready -h localhost -p 5443 -U postgres && echo Success && break
echo -n .
sleep 1
done
- name: Restore DB backup
run: PGPASSWORD=postgres psql -h localhost -p 5443 -U postgres -d givethio < /tmp/backups/givethio-staging/db_backup.sql

- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 18.17.1

- name: Install dependencies
run: npm ci

- name: Run tslint
run: npm run tslint

- name: Run build
run: npm run build

- name: Run migrations
run: npm run db:migrate:run:test

- name: Run tests
run: npm run test
env:
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
XDAI_NODE_HTTP_URL: ${{ secrets.XDAI_NODE_HTTP_URL }}
INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}
INFURA_ID: ${{ secrets.INFURA_ID }}
POLYGON_SCAN_API_KEY: ${{ secrets.POLYGON_SCAN_API_KEY }}
OPTIMISTIC_SCAN_API_KEY: ${{ secrets.OPTIMISTIC_SCAN_API_KEY }}
CELO_SCAN_API_KEY: ${{ secrets.CELO_SCAN_API_KEY }}
CELO_ALFAJORES_SCAN_API_KEY: ${{ secrets.CELO_ALFAJORES_SCAN_API_KEY }}

publish:
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Build image and push to GitHub Packages
uses: docker/build-push-action@v1
with:
username: ${{ github.actor }}
password: ${{ github.token }}
registry: ghcr.io
repository: giveth/impact-graph
add_git_labels: true
# Add branch name to docker image tag @see{@link https://github.com/docker/build-push-action/tree/releases/v1#tag_with_ref}
tag_with_ref: true
# Add commit hash to docker image tag @see{@link https://github.com/docker/build-push-action/tree/releases/v1#tag_with_sha}
tag_with_sha: true

deploy:
needs: publish
runs-on: ubuntu-latest
steps:
- name: SSH and Redeploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.STAGING_HOST_ALL }}
username: ${{ secrets.STAGING_USERNAME_ALL }}
key: ${{ secrets.STAGING_PRIVATE_KEY_ALL }}
port: ${{ secrets.SSH_PORT }}
script: |
cd giveth-all
docker-compose stop impact-graph
docker-compose pull impact-graph
docker-compose up -d impact-graph
docker image prune -a --force
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16.14.2
v18.17.1
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Impact Graph
---
### Build status
- Develop - [![CI/CD](https://github.com/Giveth/impact-graph/actions/workflows/CI-CD.yml/badge.svg?branch=develop)](https://github.com/Giveth/impact-graph/actions/workflows/CI-CD.yml)
- Staging - [![CI/CD](https://github.com/Giveth/impact-graph/actions/workflows/CI-CD.yml/badge.svg?branch=staging)](https://github.com/Giveth/impact-graph/actions/workflows/CI-CD.yml)
- Production - [![CI/CD](https://github.com/Giveth/impact-graph/actions/workflows/CI-CD.yml/badge.svg?branch=master)](https://github.com/Giveth/impact-graph/actions/workflows/CI-CD.yml)
- Develop - [![CI/CD](https://github.com/Giveth/impact-graph/actions/workflows/develop-pipeline.yml/badge.svg)](https://github.com/Giveth/impact-graph/actions/workflows/develop-pipeline.yml)
- Staging - [![CI/CD](https://github.com/Giveth/impact-graph/actions/workflows/staging-pipeline.yml/badge.svg)](https://github.com/Giveth/impact-graph/actions/workflows/staging-pipeline.yml)
- Production - [![CI/CD](https://github.com/Giveth/impact-graph/actions/workflows/master-pipeline.yml/badge.svg)](https://github.com/Giveth/impact-graph/actions/workflows/master-pipeline.yml)
---
ImpactQL is a GraphQL server, that enables rapid development of serverless impact project applications. It does this by taking care of the persistance of impact project data.

Expand Down
Loading

0 comments on commit 0092f5a

Please sign in to comment.