diff --git a/.github/actions/prettier/action.yml b/.github/actions/prettier/action.yml new file mode 100644 index 00000000..fdc68157 --- /dev/null +++ b/.github/actions/prettier/action.yml @@ -0,0 +1,25 @@ +# Define action name, description, and inputs +name: "Prettier Lint" +description: "Lint code with Prettier" +inputs: + working-directory: + required: false + description: "Working directory" + default: "." + +# Define action steps +runs: + using: "composite" + steps: + - uses: actions/setup-node@v2 + with: + node-version: 16.x + - run: | + yarn + yarn prettier --check . + shell: bash + working-directory: ${{ inputs.working-directory }} + - if: inputs.working-directory == 'packages/dashboard-v2' || inputs.working-directory == 'packages/dashboard' + run: yarn lint + shell: bash + working-directory: ${{ inputs.working-directory }} diff --git a/.github/actions/python-black-lint/action.yml b/.github/actions/python-black-lint/action.yml new file mode 100644 index 00000000..44c744d4 --- /dev/null +++ b/.github/actions/python-black-lint/action.yml @@ -0,0 +1,17 @@ +# Define action name, description, and inputs +name: "Python Black Lint" +description: "Lint python code with black" + +# Define action steps +runs: + using: "composite" + steps: + - uses: actions/setup-python@v2 + with: + python-version: "3.x" + architecture: x64 + + - run: | + pip install black + black --check . + shell: bash diff --git a/.github/actions/python-flake8-lint/action.yml b/.github/actions/python-flake8-lint/action.yml new file mode 100644 index 00000000..0fc02c06 --- /dev/null +++ b/.github/actions/python-flake8-lint/action.yml @@ -0,0 +1,22 @@ +# Define action name, description, and inputs +name: "Python Flake8 Lint" +description: "Lint python code with black" + +# Define action steps +runs: + using: "composite" + steps: + - uses: actions/setup-python@v2 + with: + python-version: "3.x" + architecture: x64 + + # E203: https://www.flake8rules.com/rules/E203.html - Whitespace before ':' + # E501: https://www.flake8rules.com/rules/E501.html - Line too long + # W503: https://www.flake8rules.com/rules/W503.html - Line break occurred before a binary operator + # W605: https://www.flake8rules.com/rules/W605.html - Invalid escape sequence + # E722: https://www.flake8rules.com/rules/E722.html - Do not use bare except, specify exception instead + - run: | + pip install flake8 + flake8 --max-line-length 88 --ignore E203,E501,W503,W605,E722 + shell: bash diff --git a/.github/workflows/lint-dockerfiles.yml b/.github/workflows/lint-dockerfiles.yml deleted file mode 100644 index 1eea156c..00000000 --- a/.github/workflows/lint-dockerfiles.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Dockerfile Lint - -on: - push: - branches: - - master - pull_request: - -jobs: - hadolint: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - dockerfile: - - docker/nginx/Dockerfile - - docker/sia/Dockerfile - - packages/dashboard/Dockerfile - - packages/dnslink-api/Dockerfile - - packages/handshake-api/Dockerfile - - packages/health-check/Dockerfile - - packages/website/Dockerfile - steps: - - uses: actions/checkout@v3 - - uses: hadolint/hadolint-action@v2.0.0 - with: - dockerfile: ${{ matrix.dockerfile }} diff --git a/.github/workflows/lint-packages-dashboard-v2.yml b/.github/workflows/lint-packages-dashboard-v2.yml deleted file mode 100644 index a8577562..00000000 --- a/.github/workflows/lint-packages-dashboard-v2.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Lint - packages/dashboard-v2 - -on: - pull_request: - paths: - - packages/dashboard-v2/** - -defaults: - run: - working-directory: packages/dashboard-v2 - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: 16.x - - - run: yarn - - run: yarn prettier --check - - run: yarn lint diff --git a/.github/workflows/lint-packages-dashboard.yml b/.github/workflows/lint-packages-dashboard.yml deleted file mode 100644 index 0df462cc..00000000 --- a/.github/workflows/lint-packages-dashboard.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Lint - packages/dashboard - -on: - pull_request: - paths: - - packages/dashboard/** - -defaults: - run: - working-directory: packages/dashboard - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: 16.x - - - run: yarn - - run: yarn prettier --check . - - run: yarn next lint diff --git a/.github/workflows/lint-packages-dnslink-api.yml b/.github/workflows/lint-packages-dnslink-api.yml deleted file mode 100644 index ea839f75..00000000 --- a/.github/workflows/lint-packages-dnslink-api.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Lint - packages/dnslink-api - -on: - pull_request: - paths: - - packages/dnslink-api/** - -defaults: - run: - working-directory: packages/dnslink-api - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: 16.x - - - run: yarn - - run: yarn prettier --check . diff --git a/.github/workflows/lint-packages-handshake-api.yml b/.github/workflows/lint-packages-handshake-api.yml deleted file mode 100644 index 3e6404c6..00000000 --- a/.github/workflows/lint-packages-handshake-api.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Lint - packages/handshake-api - -on: - pull_request: - paths: - - packages/handshake-api/** - -defaults: - run: - working-directory: packages/handshake-api - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: 16.x - - - run: yarn - - run: yarn prettier --check . diff --git a/.github/workflows/lint-packages-health-check.yml b/.github/workflows/lint-packages-health-check.yml deleted file mode 100644 index afd5d96b..00000000 --- a/.github/workflows/lint-packages-health-check.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Lint - packages/health-check - -on: - pull_request: - paths: - - packages/health-check/** - -defaults: - run: - working-directory: packages/health-check - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: 16.x - - - run: yarn - - run: yarn prettier --check . diff --git a/.github/workflows/lint-packages-website.yml b/.github/workflows/lint-packages-website.yml deleted file mode 100644 index 795ed176..00000000 --- a/.github/workflows/lint-packages-website.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Lint - packages/website - -on: - pull_request: - paths: - - packages/website/** - -defaults: - run: - working-directory: packages/website - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: 16.x - - - run: yarn - - run: yarn prettier --check . diff --git a/.github/workflows/lint-python.yml b/.github/workflows/lint-python.yml deleted file mode 100644 index 330da3d3..00000000 --- a/.github/workflows/lint-python.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Lint - Python Scripts - -on: - push: - paths: - - "**.py" - -jobs: - black: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: "3.x" - architecture: x64 - - - run: pip install black - - run: black --check . - - flake8: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: "3.x" - architecture: x64 - - - run: pip install flake8 - - # E203: https://www.flake8rules.com/rules/E203.html - Whitespace before ':' - # E501: https://www.flake8rules.com/rules/E501.html - Line too long - # W503: https://www.flake8rules.com/rules/W503.html - Line break occurred before a binary operator - # W605: https://www.flake8rules.com/rules/W605.html - Invalid escape sequence - # E722: https://www.flake8rules.com/rules/E722.html - Do not use bare except, specify exception instead - - run: flake8 --max-line-length 88 --ignore E203,E501,W503,W605,E722 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..d77e602f --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,106 @@ +name: Lint + +on: + pull_request: + +jobs: + # Determine what the prettier changes are + prettier-changes: + runs-on: ubuntu-latest + outputs: + packages: ${{ steps.filter.outputs.changes }} + steps: + # Use paths-filter to determine which paths have changes + # https://github.com/dorny/paths-filter + - uses: dorny/paths-filter@v2 + id: filter + with: + # Format of key: value. When there is a change detected in value, the + # key will be returned in the output. + filters: | + packages/dashboard: packages/dashboard/** + packages/dnslink-api: packages/dnslink-api/** + packages/handshake-api: packages/handshake-api/** + packages/health-check: packages/health-check/** + packages/website: packages/website/** + + # Determine what the dockerfile changes are + dockerfile-changes: + runs-on: ubuntu-latest + outputs: + packages: ${{ steps.filter.outputs.changes }} + steps: + # Use paths-filter to determine which paths have changes + # https://github.com/dorny/paths-filter + - uses: dorny/paths-filter@v2 + id: filter + with: + # Format of key: value. When there is a change detected in value, the + # key will be returned in the output. + filters: | + docker/nginx/Dockerfile: docker/nginx/Dockerfile + docker/sia/Dockerfile: docker/sia/Dockerfile + packages/dashboard/Dockerfile: packages/dashboard/Dockerfile + packages/dnslink-api/Dockerfile: packages/dnslink-api/Dockerfile + packages/handshake-api/Dockerfile: packages/handshake-api/Dockerfile + packages/health-check/Dockerfile: packages/health-check/Dockerfile + packages/website/Dockerfile: packages/website/Dockerfile + + # Run the prettier lint if there are changes to any of the prettier packages + prettier: + needs: prettier-changes + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + working-directory: ${{ fromJSON(needs.prettier-changes.outputs.packages) }} + steps: + - uses: actions/checkout@v2 + - name: Run Prettier Action + uses: ./.github/actions/prettier + with: + working-directory: ${{ matrix.working-directory }} + + # Run the hadolint dockefile lint if there are changes to any of the + # dockerfiles + hadolint: + needs: dockerfile-changes + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + dockerfile: ${{ fromJSON(needs.dockerfile-changes.outputs.packages) }} + steps: + - uses: actions/checkout@v3 + - uses: hadolint/hadolint-action@v2.0.0 + with: + dockerfile: ${{ matrix.dockerfile }} + + # Determine if there are python changes + python-changes: + runs-on: ubuntu-latest + outputs: + # Check if the changed status of py is true + updates: steps.changes.outputs.py == 'true' + steps: + # Use paths-filter to determine which paths have changes + # https://github.com/dorny/paths-filter + - uses: dorny/paths-filter@v2 + id: changes + with: + filters: | + py: "**.py" + + # Run the hadolint dockefile lint if there are changes to any of the + # dockerfiles + python-lint: + needs: python-changes + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run Black python linter + if: ${{ needs.python-changes.outputs.updates }} + uses: ./.github/actions/python-black-lint + - name: Run Flake8 python linter + if: ${{ needs.python-changes.outputs.updates }} + uses: ./.github/actions/python-flake8-lint diff --git a/docker/sia/Dockerfile b/docker/sia/Dockerfile index 953dd27c..bbeb17dd 100644 --- a/docker/sia/Dockerfile +++ b/docker/sia/Dockerfile @@ -12,5 +12,6 @@ FROM nebulouslabs/sia:1.5.6 COPY --from=sia-builder /go/bin/ /usr/bin/ +# rename binaries to old siac siad naming RUN if [ -f "/usr/bin/skyd" ]; then mv /usr/bin/skyd /usr/bin/siad; fi && \ if [ -f "/usr/bin/skyc" ]; then mv /usr/bin/skyc /usr/bin/siac; fi diff --git a/packages/dashboard/README.md b/packages/dashboard/README.md index ca73d277..4b8a971f 100644 --- a/packages/dashboard/README.md +++ b/packages/dashboard/README.md @@ -1,3 +1,5 @@ +# Dashboard + This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). ## Getting Started diff --git a/packages/health-check/src/checks/critical.js b/packages/health-check/src/checks/critical.js index 127ebd8a..939fb556 100644 --- a/packages/health-check/src/checks/critical.js +++ b/packages/health-check/src/checks/critical.js @@ -195,6 +195,7 @@ async function blockerHealthCheck(done) { done({ name: "blocker", time: calculateElapsedTime(time), ...data }); } +// genericAccessCheck async function genericAccessCheck(name, url) { const authCookie = await getAuthCookie(); const time = process.hrtime(); diff --git a/setup-scripts/health-checker.py b/setup-scripts/health-checker.py index 091ebe30..83457b02 100755 --- a/setup-scripts/health-checker.py +++ b/setup-scripts/health-checker.py @@ -42,7 +42,7 @@ DISK_USAGE_DUMP_LOG = "../../devops/disk-monitor/disk-usage-dump.log" setup() - +# run_checks runs the health checks async def run_checks(): print("Running Skynet portal health checks") try: