Skip to content

Commit

Permalink
Merge branch 'main' into lemmih/cf-listing-working
Browse files Browse the repository at this point in the history
  • Loading branch information
lemmih authored Dec 11, 2023
2 parents 39e82db + bacd430 commit d6e6dfc
Show file tree
Hide file tree
Showing 88 changed files with 2,817 additions and 2,655 deletions.
6 changes: 5 additions & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ env:
commonjs: true
es2021: true
shared-node-browser: true
extends: eslint:recommended
extends:
- eslint:recommended
- plugin:@typescript-eslint/recommended
overrides: []
parserOptions:
ecmaVersion: latest
sourceType: module
rules: {}
plugins:
- "@typescript-eslint"
38 changes: 0 additions & 38 deletions .github/workflows/deploy-benchmark.yml

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/deploy-cf-latest-snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Deploy CF latest-snapshot
on:
pull_request:
paths:
- 'cf/latest-snapshot/**'
- '.github/workflows/deploy-cf-latest-snapshot.yml'
push:
paths:
- 'cf/latest-snapshot/**'
- '.github/workflows/deploy-cf-latest-snapshot.yml'
workflow_dispatch:

jobs:
check-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Deployment check
uses: cloudflare/wrangler-action@v3
with:
workingDirectory: "cf/latest-snapshot"
command: deploy --dry-run
- name: Deploy
if: github.ref == 'refs/heads/main' && ( github.event_name == 'push' || github.event_name == 'workflow_dispatch' )
uses: cloudflare/wrangler-action@v3
with:
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
workingDirectory: "cf/latest-snapshot"
29 changes: 29 additions & 0 deletions .github/workflows/deploy-cf-prune-latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Deploy CF prune-latest
on:
pull_request:
paths:
- 'cf/prune-latest/**'
- '.github/workflows/deploy-cf-prune-latest.yml'
push:
paths:
- 'cf/prune-latest/**'
- '.github/workflows/deploy-cf-prune-latest.yml'
workflow_dispatch:

jobs:
check-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Deployment check
uses: cloudflare/wrangler-action@v3
with:
workingDirectory: "cf/prune-latest"
command: deploy --dry-run
- name: Deploy
if: github.ref == 'refs/heads/main' && ( github.event_name == 'push' || github.event_name == 'workflow_dispatch' )
uses: cloudflare/wrangler-action@v3
with:
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
workingDirectory: "cf/prune-latest"
5 changes: 4 additions & 1 deletion .github/workflows/deploy-daily-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
paths:
- 'terraform/daily_snapshot/**'
- 'terraform/modules/daily_snapshot/**'
# This needs to be declared explicitly so that the job is actually
# run when moved out of draft.
types: [opened, synchronize, reopened, ready_for_review]
push:
branches:
- main
Expand Down Expand Up @@ -36,7 +39,7 @@ jobs:
r2_access_key: ${{ secrets.R2_ACCESS_KEY }}
r2_secret_key: ${{ secrets.R2_SECRET_KEY }}
slack_token: ${{ secrets.SLACK_TOKEN }}
working_directory: terraform/daily_snapshot
working_directory: terraform/daily_snapshot/prod
environment: Snapshot Service
new_relic_account_id: ${{ secrets.NEW_RELIC_ACCOUNT_ID }}
new_relic_api_key: ${{ secrets.NEW_RELIC_API_KEY }}
40 changes: 0 additions & 40 deletions .github/workflows/deploy-lotus-mainnet.yml

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/deploy-snapshot-function.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,3 @@ jobs:
- name: Deploy Redirect Snapshot function
if: github.ref == 'refs/heads/main' && ( github.event_name == 'push' || github.event_name == 'workflow_dispatch' )
run: doctl serverless deploy .

deploy-monitor-snapshot-function:
name: Forest Snapshot Check
runs-on: ubuntu-latest
env:
TF_VAR_do_token: ${{ secrets.DO_TOKEN }}
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
defaults:
run:
shell: bash
working-directory: do_function/monitor_snapshots
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DO_TOKEN }}

- name: Configure serverless
run: |
doctl serverless install
doctl serverless connect monitor-spaces
- name: Deploy Snapshot Checks function
if: github.ref == 'refs/heads/main' && ( github.event_name == 'push' || github.event_name == 'workflow_dispatch' )
run: doctl serverless deploy . --remote-build
4 changes: 2 additions & 2 deletions .github/workflows/lintingci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
key: tflint-${{ hashFiles('.tflint.hcl') }}

- name: Setup TFLint
uses: terraform-linters/setup-tflint@v3
uses: terraform-linters/setup-tflint@v4
with:
tflint_version: v0.44.1

Expand All @@ -42,7 +42,7 @@ jobs:
uses: actions/checkout@v4

- name: Setup terraform
uses: hashicorp/setup-terraform@v2
uses: hashicorp/setup-terraform@v3

- name: Show version
run: terraform --version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scripts-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Run rubocop
run: |
gem install rubocop --no-document
rubocop scripts/ terraform/modules/benchmark/ # TODO: Apply rubocop to terraform/modules/
rubocop scripts/ # TODO: Apply rubocop to terraform/modules/
run-js-linters:
runs-on: ubuntu-latest
steps:
Expand Down
27 changes: 0 additions & 27 deletions .github/workflows/tests-daily-snapshot.yml

This file was deleted.

16 changes: 15 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
autofix_prs: true
autoupdate_branch: ''
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: weekly
skip: []
submodules: false

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: detect-private-key
- id: detect-aws-credentials
# This is allowed due to the CI environment where no credentials are set.
args: ['--allow-missing-credentials']

- repo: https://github.com/Yelp/detect-secrets
rev: v1.4.0
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ That's it! From now on, every time you commit changes to your project, these hoo
## Overview
The Terraform folder contains terraform scripts to automate the setup of droplets on DigitalOcean. These scripts enable the configuration of essential infrastructure required for running Forest Mainnet, Calibnet, or Lotus Mainnet nodes. The script automates several steps, including:
The Terraform folder contains terraform scripts to automate the setup of droplets on DigitalOcean. These scripts enable the configuration of essential infrastructure required for running Forest Mainnet or Calibnet Filecoin node. The script automates several steps, including:
- Booting up a New Droplet: It initializes a new droplet with specified parameters such as image, name, region, and size.
- Volume Attachment (optional): The script can optionally attach a storage volume to the droplet if the user specifies so (attach_volume variable set to true). This feature primarily runs on the Mainnet but can also be applied to the Calibnet if set to true. To ensure compliance with device identifier restrictions on DigitalOcean, any "-" characters in the volume name are automatically replaced with "_" when mounting the volume on the droplet.
- Volume Attachment (optional): The script can optionally attach a storage volume to the droplet if the user specifies so (attach_volume variable set to false). To ensure compliance with device identifier restrictions on DigitalOcean, any "-" characters in the volume name are automatically replaced with "_" when mounting the volume on the droplet.
- Running Initialization Script: The `user-data.sh` or `lotus.sh` script is executed during the droplet's initialization. This script is powered by the Terraform engine and allows dynamic insertion of variables from the `terraform.tfvars` file. It handles crucial tasks such as creating a new user, configuring SSH settings, restricting SSH access, and managing Docker-related setups. Its purpose is to specifically run the Mainnet or Calibnet chain based on the specifications provided in the Terraform script. Additionally, it initializes Watchtower to ensure the Forest images are up to date and configures the New Relic infrastructure agent and Openmetrics New Relic container exclusively on the forest nodes.
- Running Initialization Script: The `user-data.sh` script is executed during the droplet's initialization. This script is powered by the Terraform engine and allows dynamic insertion of variables from the `terraform.tfvars` file. It handles crucial tasks such as creating a new user, configuring SSH settings, restricting SSH access, and managing Docker-related setups. Its purpose is to specifically run the Mainnet or Calibnet chain based on the specifications provided in the Terraform script. Additionally, it initializes Watchtower to ensure the Forest images are up to date and configures the New Relic infrastructure agent and Openmetrics New Relic container exclusively on the forest nodes.

## Requirements
The droplet requirements to run Forest Mainnet, Calibnet or lotus mainnet nodes include:
The droplet requirements to run Forest Mainnet or Calibnet nodes include:
- RAM: 8GB
- VCPU: 1
- Disk Size: >100 GB
Expand All @@ -74,7 +74,7 @@ The user's local machine requirements include the following:
To implement the infrastructure, run the following:
- Create an `ssh-key` to be added to the DigitalOcean list and store the fingerprint for use in the next few steps; you can check more details [here](https://docs.digitalocean.com/products/droplets/how-to/add-ssh-keys/to-team/)
- Create a space on DigitalOcean with any preferred unique name, then add the bucket name and endpoint to the `backend.tf` file located in the `forest-mainnet`, `forest-calibnet` or `lotus-mainnet` directory, depending on which one you plan to run.
- Create a space on DigitalOcean with any preferred unique name, then add the bucket name and endpoint to the `backend.tf` file located in the `forest-mainnet` or `forest-calibnet` directory, depending on which one you plan to run.
- Generate `digitalocean_api_token` from DigitalOcean console; you can check [here](https://docs.digitalocean.com/reference/api/create-personal-access-token/) for more details.
Expand All @@ -95,11 +95,11 @@ export TF_VAR_NR_LICENSE_KEY=
```
Then save the file and restart the terminal for the changes to take effect.

- Navigate to the terraform directory and run `make init_calib` for calibnet, `make init_main` for mainnet, or `make init_lt_main` for lotus mainnet to initialize and verify variables.
- Navigate to the terraform directory and run `make init_calib` for calibnet or `make init_main` for mainnet to initialize and verify variables.

- Run `make plan_calib` for calibnet, `make plan_main` for mainnet, or `make plan_lt_main` for lotus mainnet in the terraform directory to view all the configured resources.
- Run `make plan_calib` for calibnet, or `make plan_main` for mainnet, or `make plan_lt_main` in the terraform directory to view all the configured resources.

- To create the infrastructure, run `make apply_calib` for calibnet, `make apply_main` for mainnet, or `make apply_lt_main` for lotus mainnet in the terraform directory.
- To create the infrastructure, run `make apply_calib` for calibnet, or `make apply_main` for mainnet in the terraform directory.

## Collaborators
Feel free to contribute to the codebase by resolving any open issues, refactoring, adding new features, writing test cases, or any other way to make the project better and helpful to the community. Feel free to fork and send pull requests.
Expand Down
16 changes: 8 additions & 8 deletions archival-snapshots-generate/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions cf/latest-snapshot/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# http://editorconfig.org
root = true

[*]
indent_style = tab
tab_width = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.yml]
indent_style = space
1 change: 1 addition & 0 deletions cf/latest-snapshot/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.wrangler
Loading

0 comments on commit d6e6dfc

Please sign in to comment.