Skip to content

Commit

Permalink
Add GitHub Action to check linter and formatter (#17)
Browse files Browse the repository at this point in the history

---------

Co-authored-by: Filip Lelek <filip.lelek@neti-soft.com>
  • Loading branch information
Filip-L and Filip Lelek committed Jun 14, 2024
1 parent 98e5ed8 commit 88c0fab
Show file tree
Hide file tree
Showing 18 changed files with 2,512 additions and 2,773 deletions.
122 changes: 61 additions & 61 deletions .github/workflows/deploy-to-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,76 +3,76 @@ name: Deploy SSA Bot to Production Container Service
on:
push:
tags:
- '*'
- "*"

jobs:
deploy_to_production_container_service:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Login to Amazon ECR Public
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: 'true'
- name: Login to Amazon ECR Public
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: "true"
registry-type: public

- name: Build and tag Docker image
run: |
echo "Building Docker image..."
docker build -t "public.ecr.aws/b3c4u5n1/filplus-ssa-bot:${{ github.ref_name }}" .
- name: Push Docker image to ECR
run: |
echo "Pushing Docker image to ECR..."
docker push "public.ecr.aws/b3c4u5n1/filplus-ssa-bot:${{ github.ref_name }}"
- name: Build and tag Docker image
run: |
echo "Building Docker image..."
docker build -t "public.ecr.aws/b3c4u5n1/filplus-ssa-bot:${{ github.ref_name }}" .
- name: Deploy to Lightsail Container Service
run: |
# Define containers.json with desired settings
echo '{
"filplus-ssa-bot": {
"image": "public.ecr.aws/b3c4u5n1/filplus-ssa-bot:${{ github.ref_name }}",
"ports": {
"3000": "HTTP"
},
"environment": {
"AWS_ACCESS_KEY_ID": "${{secrets.AWS_ACCESS_KEY_ID}}",
"AWS_SECRET_ACCESS_KEY": "${{secrets.AWS_SECRET_ACCESS_KEY}}",
"BACKEND_API_URL": "${{secrets.PROD_BACKEND_API_URL}}",
"DMOB_API_KEY": "${{secrets.DMOB_API_KEY}}",
"DMOB_API_URL": "${{secrets.DMOB_API_URL}}"
- name: Push Docker image to ECR
run: |
echo "Pushing Docker image to ECR..."
docker push "public.ecr.aws/b3c4u5n1/filplus-ssa-bot:${{ github.ref_name }}"
- name: Deploy to Lightsail Container Service
run: |
# Define containers.json with desired settings
echo '{
"filplus-ssa-bot": {
"image": "public.ecr.aws/b3c4u5n1/filplus-ssa-bot:${{ github.ref_name }}",
"ports": {
"3000": "HTTP"
},
"environment": {
"AWS_ACCESS_KEY_ID": "${{secrets.AWS_ACCESS_KEY_ID}}",
"AWS_SECRET_ACCESS_KEY": "${{secrets.AWS_SECRET_ACCESS_KEY}}",
"BACKEND_API_URL": "${{secrets.PROD_BACKEND_API_URL}}",
"DMOB_API_KEY": "${{secrets.DMOB_API_KEY}}",
"DMOB_API_URL": "${{secrets.DMOB_API_URL}}"
}
}
}' > containers.json
# Define public-endpoint.json
echo '{
"containerName": "filplus-ssa-bot",
"containerPort": 3000,
"healthCheck": {
"healthyThreshold": 2,
"unhealthyThreshold": 2,
"timeoutSeconds": 30,
"intervalSeconds": 60,
"path": "/health",
"successCodes": "200"
}
}
}' > containers.json
# Define public-endpoint.json
echo '{
"containerName": "filplus-ssa-bot",
"containerPort": 3000,
"healthCheck": {
"healthyThreshold": 2,
"unhealthyThreshold": 2,
"timeoutSeconds": 30,
"intervalSeconds": 60,
"path": "/health",
"successCodes": "200"
}
}' > public-endpoint.json
# Deploy to Lightsail Container Service
aws lightsail create-container-service-deployment \
--service-name filplus-ssa-bot-prod \
--region us-east-1 \
--containers file://containers.json \
--public-endpoint file://public-endpoint.json
}' > public-endpoint.json
# Deploy to Lightsail Container Service
aws lightsail create-container-service-deployment \
--service-name filplus-ssa-bot-prod \
--region us-east-1 \
--containers file://containers.json \
--public-endpoint file://public-endpoint.json
120 changes: 60 additions & 60 deletions .github/workflows/deploy-to-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,69 +10,69 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Login to Amazon ECR Public
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: 'true'
- name: Login to Amazon ECR Public
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: "true"
registry-type: public

- name: Build and tag Docker image
run: |
echo "Building Docker image..."
docker build -t "public.ecr.aws/b3c4u5n1/filplus-ssa-bot:${{ github.ref_name }}" .
- name: Push Docker image to ECR
run: |
echo "Pushing Docker image to ECR..."
docker push "public.ecr.aws/b3c4u5n1/filplus-ssa-bot:${{ github.ref_name }}"
- name: Build and tag Docker image
run: |
echo "Building Docker image..."
docker build -t "public.ecr.aws/b3c4u5n1/filplus-ssa-bot:${{ github.ref_name }}" .
- name: Deploy to Lightsail Container Service
run: |
# Define containers.json with desired settings
echo '{
"filplus-ssa-bot": {
"image": "public.ecr.aws/b3c4u5n1/filplus-ssa-bot:${{ github.ref_name }}",
"ports": {
"3000": "HTTP"
},
"environment": {
"AWS_ACCESS_KEY_ID": "${{secrets.AWS_ACCESS_KEY_ID}}",
"AWS_SECRET_ACCESS_KEY": "${{secrets.AWS_SECRET_ACCESS_KEY}}",
"BACKEND_API_URL": "${{secrets.STAGING_BACKEND_API_URL}}",
"DMOB_API_KEY": "${{secrets.DMOB_API_KEY}}",
"DMOB_API_URL": "${{secrets.DMOB_API_URL}}"
- name: Push Docker image to ECR
run: |
echo "Pushing Docker image to ECR..."
docker push "public.ecr.aws/b3c4u5n1/filplus-ssa-bot:${{ github.ref_name }}"
- name: Deploy to Lightsail Container Service
run: |
# Define containers.json with desired settings
echo '{
"filplus-ssa-bot": {
"image": "public.ecr.aws/b3c4u5n1/filplus-ssa-bot:${{ github.ref_name }}",
"ports": {
"3000": "HTTP"
},
"environment": {
"AWS_ACCESS_KEY_ID": "${{secrets.AWS_ACCESS_KEY_ID}}",
"AWS_SECRET_ACCESS_KEY": "${{secrets.AWS_SECRET_ACCESS_KEY}}",
"BACKEND_API_URL": "${{secrets.STAGING_BACKEND_API_URL}}",
"DMOB_API_KEY": "${{secrets.DMOB_API_KEY}}",
"DMOB_API_URL": "${{secrets.DMOB_API_URL}}"
}
}
}' > containers.json
# Define public-endpoint.json
echo '{
"containerName": "filplus-ssa-bot",
"containerPort": 3000,
"healthCheck": {
"healthyThreshold": 2,
"unhealthyThreshold":5,
"timeoutSeconds": 30,
"intervalSeconds": 60,
"path": "/health",
"successCodes": "200"
}
}
}' > containers.json
# Define public-endpoint.json
echo '{
"containerName": "filplus-ssa-bot",
"containerPort": 3000,
"healthCheck": {
"healthyThreshold": 2,
"unhealthyThreshold":5,
"timeoutSeconds": 30,
"intervalSeconds": 60,
"path": "/health",
"successCodes": "200"
}
}' > public-endpoint.json
# Deploy to Lightsail Container Service
aws lightsail create-container-service-deployment \
--service-name filplus-ssa-bot \
--region us-east-1 \
--containers file://containers.json \
--public-endpoint file://public-endpoint.json
}' > public-endpoint.json
# Deploy to Lightsail Container Service
aws lightsail create-container-service-deployment \
--service-name filplus-ssa-bot \
--region us-east-1 \
--containers file://containers.json \
--public-endpoint file://public-endpoint.json
48 changes: 48 additions & 0 deletions .github/workflows/pr_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Test linter and code formatter

on:
pull_request:
push:
branches:
- main

jobs:
lint:
strategy:
fail-fast: true

name: Run ESLint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 16

- name: Install Dependencies
run: npm ci

- name: Run ESLint
run: npm run eslint

formatting:
strategy:
fail-fast: true

name: Run Prettier
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 16

- name: Install Dependencies
run: npm ci

- name: Run Prettier
run: npm run prettier
2 changes: 1 addition & 1 deletion PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ Before submitting your pull request, please review the following checklist:

## Additional Information

Any additional information, configuration, or data that might be necessary to reproduce the issue or test the feature.
Any additional information, configuration, or data that might be necessary to reproduce the issue or test the feature.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
# Filplus SSA Bot

Welcome to the "Filplus SSA Bot" (Subsequent Allocation Bot) repository. This bot is an integral part of the Filplus program, specifically designed to enhance the efficiency and effectiveness of the Large Dataset Notaries (LDN) program.

## Overview

The Filplus SSA Bot, written in <code>TypeScript</code>, plays a crucial role in managing the allocation of datacap within the LDN program. It is programmed to automatically launch every 12 hours, performing a thorough scan of all active datacap requests. For those requests where more than 75% of the allocated datacap in the last tranche has been consumed, the bot initiates the process of assigning a new tranche.

## Key Features

- **Automated Scanning**: Every 12 hours, the bot scans all active datacap requests within the LDN program.
- **Tranche Allocation**: When a request has consumed over 75% of its last allocated datacap, the bot triggers the allocation of a new tranche.
- **Notary Approval**: Each new tranche allocation must be proposed and approved by two different notaries to ensure fairness and transparency.

# Related Projects

- [Fil+ Backend](https://github.com/filecoin-project/filplus-backend)
- [Fil+ Registry](https://github.com/filecoin-project/filplus-registry)
- [Fil+ Application Repository (Falcon)](https://github.com/filecoin-project/filecoin-plus-falcon)

## Contribution

As an open-source project, we welcome and encourage the community to contribute to the Filplus SSA Bot. Your insights and improvements are valuable to us. Here's how you can contribute:

- **Fork the Repository**: Start by forking the repository to your GitHub account.
Expand All @@ -28,12 +33,15 @@ As an open-source project, we welcome and encourage the community to contribute
Please read through our [CONTRIBUTING.md](CONTRIBUTING.md) file for detailed instructions on how to contribute.

## Usage

This bot is specifically designed as a part of the Filplus program and is not intended for general installation or standalone use. Its primary function is to automate certain processes within the LDN program, contributing to the overall efficiency and effectiveness of datacap allocation.

## Support and Community

If you have any questions, suggestions, or need assistance, please reach out to our community channels. We strive to build a welcoming and supportive environment for all our contributors and users.

## License

This project is dual-licensed under the `Permissive License Stack`, which means you can choose to use the project under either:

- The Apache License 2.0, which is a free and open-source license, focusing on patent rights and copyright notices. For more details, see the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0).
Expand All @@ -42,4 +50,4 @@ This project is dual-licensed under the `Permissive License Stack`, which means

You may not use the contents of this repository except in compliance with one of these licenses. For an extended clarification of the intent behind the choice of licensing, please refer to the `LICENSE` file in this repository or visit [Permissive License Stack Explanation](https://protocol.ai/blog/announcing-the-permissive-license-stack/).

For the full license text, please see the [LICENSE](LICENSE) file in this repository.
For the full license text, please see the [LICENSE](LICENSE) file in this repository.
2 changes: 2 additions & 0 deletions deps/filecoin-content/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# filecoin-content

## Description

Just a folder containing Json files.
Needed to track notaries and "exception" clients as well as e-fil clients.
Loading

0 comments on commit 88c0fab

Please sign in to comment.