-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update configurations, Dockerfile setup, linting rules, and GitHub wo…
…rkflows. Add ESLint and EditorConfig files. Include backup workflows to S3 and workspace backups.
- Loading branch information
Showing
101 changed files
with
15,107 additions
and
1,425 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"presets": ["@babel/preset-env", "@babel/preset-react", "@babel/preset-typescript"] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
|
||
# Use Miniconda base image | ||
FROM continuumio/miniconda3 | ||
|
||
# Install Node.js version 20.9.0 (correcting the command) | ||
RUN conda install -c conda-forge nodejs=20.9.0 | ||
|
||
# Install Yarn (using npm, which comes with Node.js) | ||
RUN npm install -g yarn | ||
|
||
# Copy both the environment.yml for Conda and package.json (and yarn.lock if available) for Yarn | ||
COPY environment.yml /tmp/environment.yml | ||
COPY package.json yarn.lock* /tmp/ | ||
|
||
# Use the environment.yml to create the Conda environment | ||
RUN conda env create -f /tmp/environment.yml | ||
|
||
# Make RUN commands use the new environment | ||
SHELL ["conda", "run", "-n", "pre-commit-env", "/bin/bash", "-c"] | ||
|
||
RUN pip install checkov terrascan | ||
|
||
SHELL ["docker run --rm -i hadolint/hadolint < Dockerfile"] | ||
|
||
SHELL ["docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/Library/Caches:/root/.cache/ aquasec/trivy image [my-frontend-app] " ] | ||
|
||
# Install JavaScript dependencies with Yarn | ||
RUN cd /tmp && yarn install | ||
|
||
# Copy the installed JavaScript dependencies (and other necessary files) into the working directory | ||
COPY . /app | ||
WORKDIR /app | ||
|
||
# The code below ensures that the environment is activated on startup | ||
RUN echo "conda activate pre-commit-env" >> ~/.bashrc | ||
|
||
# (Optional) Install JupyterLab in the Conda environment if you need it | ||
RUN conda run -n pre-commit-env pip install jupyterlab | ||
|
||
# Set the default command for the container. Adjust as needed. | ||
CMD ["conda", "run", "-n", "pre-commit-env", "your-command-here"] | ||
|
||
name: Lint and Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- feature/** | ||
pull_request: | ||
|
||
jobs: | ||
lint-dockerfiles: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
# Lint Dockerfile in root directory | ||
- name: Lint Root Dockerfile | ||
uses: hadolint/hadolint-action@v1.5.0 | ||
with: | ||
dockerfile: ./Dockerfile | ||
|
||
# Lint Dockerfile in .devcontainer directory | ||
- name: Lint Devcontainer Dockerfile | ||
uses: hadolint/hadolint-action@v1.5.0 | ||
with: | ||
dockerfile: ./.devcontainer/Dockerfile | ||
|
||
build: | ||
needs: lint-dockerfiles | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Build Docker Image from Root | ||
run: | | ||
docker build -t my-app:latest . | ||
|
||
- name: Build Docker Image from .devcontainer | ||
run: | | ||
docker build -f ./.devcontainer/Dockerfile -t my-devcontainer:latest . | ||
|
||
# Use Miniconda base image | ||
FROM continuumio/miniconda3 | ||
|
||
# Install dependencies, etc. | ||
|
||
# Copy your application's source code and the entrypoint script | ||
COPY . /app | ||
COPY entrypoint.sh /usr/local/bin/entrypoint.sh | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Make the entrypoint script executable | ||
RUN chmod +x /usr/local/bin/entrypoint.sh | ||
|
||
# Set the entrypoint to run your script | ||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] | ||
|
||
|
||
# Expose any ports your application uses (e.g., for a web server) | ||
EXPOSE 8888 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "21XO-MVP", | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
"context": ".." | ||
}, | ||
"settings": { | ||
"terminal.integrated.defaultProfile.linux": "bash" | ||
}, | ||
"postCreateCommand": "echo 'Remember to manually create and activate the Conda environment, then install JupyterLab and npm packages'", | ||
"remoteUser": "vscode", | ||
"extensions": [ | ||
"dbaeumer.vscode-eslint", | ||
"GitHub.codespaces", | ||
"ms-azuretools.vscode-docker", | ||
"cweijan.vscode-postgresql-client2", | ||
"tintinweb.solidity-visual-auditor", | ||
"github.vscode-github-actions", | ||
"AvneeshAgarwal.thirdweb-snippets", | ||
"GitHub.copilot", | ||
"streetsidesoftware.code-spell-checker", | ||
"VisualStudioExptTeam.vscodeintellicode", | ||
"ms-python.python", | ||
"bmewburn.vscode-intelephense-client", | ||
"NomicFoundation.hardhat-solidity", | ||
"redhat.vscode-yaml", | ||
"ms-dotnettools.vscode-dotnet-runtime", | ||
"eamodio.gitlens", | ||
"ms-vscode-remote.remote-containers", | ||
"ms-vscode-remote.remote-wsl" | ||
], | ||
"forwardPorts": [3000, 8888] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# EditorConfig is awesome: https://EditorConfig.org | ||
|
||
# Top-level EditorConfig file | ||
root = true | ||
|
||
# Unix-style newlines with a newline ending every file | ||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
|
||
# Matches multiple files with brace expansion notation | ||
# Set indent style and size for JavaScript, JSON, HTML, CSS, and similar files | ||
[*.{js,json,html,css,scss,md}] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
# Override for Python files | ||
[*.py] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
# Override for Java files | ||
[*.java] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
# Override for C++ files | ||
[*.{cpp,h}] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
# Markdown files (Markdownlint often prefers no trailing whitespace) | ||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
env: | ||
browser: true | ||
es2021: true | ||
node: true | ||
extends: | ||
- eslint:recommended | ||
- plugin:@typescript-eslint/recommended | ||
- plugin:react/recommended | ||
- plugin:react-hooks/recommended | ||
- airbnb | ||
- airbnb/hooks | ||
- airbnb-typescript | ||
parser: '@typescript-eslint/parser' | ||
parserOptions: | ||
ecmaFeatures: | ||
jsx: true | ||
ecmaVersion: 12 # Equivalent to 2021 | ||
sourceType: 'module' | ||
project: './config/tsconfig.json' # Specify the path to your tsconfig if you're using TypeScript | ||
plugins: | ||
- '@typescript-eslint' | ||
- react | ||
- react-hooks | ||
rules: | ||
indent: ['error', 2] | ||
quotes: ['error', 'single'] | ||
semi: ['error', 'always'] | ||
"@typescript-eslint/no-unused-vars": ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }] | ||
"react/jsx-filename-extension": [1, { "extensions": [".tsx", ".jsx"] }] | ||
"react/jsx-uses-react": "off" | ||
"react/react-in-jsx-scope": "off" | ||
"react-hooks/rules-of-hooks": 'error' # Checks rules of Hooks | ||
"react-hooks/exhaustive-deps": 'warn' # Checks effect dependencies | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
# These are supported funding model platforms | ||
|
||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [XOwlPost] | ||
patreon: # Replace with a single Patreon username | ||
open_collective: # Replace with a single Open Collective username | ||
ko_fi: # Replace with a single Ko-fi username | ||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | ||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | ||
liberapay: # Replace with a single Liberapay username | ||
issuehunt: # Replace with a single IssueHunt username | ||
otechie: # Replace with a single Otechie username | ||
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry | ||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['21XO.eth'] | ||
# These are supported funding model platforms | ||
|
||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [XOwlPost] | ||
patreon: # Replace with a single Patreon username | ||
open_collective: # Replace with a single Open Collective username | ||
ko_fi: # Replace with a single Ko-fi username | ||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | ||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | ||
liberapay: # Replace with a single Liberapay username | ||
issuehunt: # Replace with a single IssueHunt username | ||
otechie: # Replace with a single Otechie username | ||
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry | ||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['21XO.eth'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- name: Backup to S3 | ||
run: | ||
aws s3 sync . s3://backup-workflow/codespace-wip --endpoint-url=https://gateway.storjshare.io --exclude ".git/*" --exclude ".next/*" --exclude ".node_modules/*" | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Backup Workspace | ||
|
||
on: | ||
schedule: | ||
- cron: '0 */4 * * *' # Runs every 4 hours | ||
|
||
jobs: | ||
backup: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Configure Git | ||
run: | | ||
git config --global user.name 'XOwlPost' | ||
git config --global user.email 'xofidelius@gmail.com' | ||
- name: Commit and Push Backup | ||
run: | | ||
git pull origin main | ||
git add . | ||
git commit -m "Automated backup $(date)" | ||
git push origin main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
jobs: | ||
security_checks: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Cache Python dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
- name: Install and Run Terrascan | ||
run: | | ||
pip install terrascan | ||
terrascan scan -d ./ -t aws | ||
# This step installs Terrascan and runs a scan on the AWS resources defined in the repository. | ||
|
||
# Add similar steps for Checkov, Ivy, and any other tools, adjusting the installation and execution commands as necessary. | ||
# Remember to add the installation step for each tool and then execute it against your codebase. | ||
|
||
# Example step for Checkov (assuming it's needed): | ||
- name: Install and Run Checkov | ||
run: | | ||
pip install checkov | ||
checkov -d . | ||
- name: Paths Filter (example for changed paths) | ||
uses: dorny/paths-filter@v2 | ||
with: | ||
filters: 'src/**,test/**' | ||
# This step uses the paths-filter action to determine if subsequent steps should run based on changes in src or test directories. | ||
|
||
- name: Check for TODO comments | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Run TODO check | ||
run: | | ||
# Fetch the full history so diffs can be made against the main branch | ||
git fetch --no-tags --prune --depth=50 origin +refs/heads/main:refs/remotes/origin/main | ||
# This script checks for TODO comments added in the diffs against the main branch. | ||
git diff origin/main...HEAD | grep -i "TODO" | ||
if [ $? -eq 0 ]; then | ||
echo "New TODO comments found in the diff." | ||
exit 1 | ||
else | ||
echo "No new TODO comments in the diff." | ||
fi | ||
|
||
- name: git diff --check | ||
uses: joel-coffman/action-git-diff-check@0.1.1 | ||
# This action checks for conflict markers and whitespace errors in the git diff output. | ||
|
||
- name: No new @ts-nocheck | ||
uses: tanmayairbase/tscheck-action-shell@6.0.0 | ||
# This action checks for new @ts-nocheck comments introduced in TypeScript files. | ||
|
||
- name: Install Trunk CLI | ||
run: | | ||
yarn global add trunk-cli | ||
trunk init | ||
env: | ||
TRUNK_ACCESS_TOKEN: ${{ secrets.TRUNK_API_KEY }} | ||
|
||
|
||
- name: Run Trunk Checks | ||
run: | | ||
trunk pull --all | ||
trunk check --all | ||
trunk push --all | ||
# Adjust these commands based on the actual usage and options available in Trunk CLI. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Pull Request | ||
on: [pull_request, workflow_dispatch] | ||
concurrency: | ||
group: ${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
permissions: read-all | ||
|
||
jobs: | ||
trunk_check: | ||
name: Trunk Check Runner | ||
runs-on: ubuntu-latest | ||
permissions: | ||
checks: write # For trunk to post annotations | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 | ||
|
||
- name: Trunk Check | ||
uses: ./ # external users, use: trunk-io/trunk-action@v1 | ||
|
||
action_tests: | ||
name: Action tests | ||
uses: ./.github/workflows/action_tests.yaml | ||
|
||
repo_tests: | ||
name: Repository tests | ||
uses: ./.github/workflows/repo_tests.yaml | ||
|
||
docker_repo_tests: | ||
name: Repository tests (docker) | ||
uses: ./.github/workflows/docker_repo_tests.yaml |
Oops, something went wrong.