diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 140dc86cbc9..00000000000 --- a/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": ["stage-0", "react", "es2015"], - "plugins": [ - "transform-runtime", - ["babel-root-import", { - "rootPathSuffix": "src" - }] - ], - "env": { - "development": { - "presets": ["react-hmre"] - } - } -} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000000..c6c8b362193 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 0cf87d430ca..00000000000 --- a/.eslintrc +++ /dev/null @@ -1,32 +0,0 @@ -{ - "extends": "airbnb", - "plugins": [ - "babel" - ], - "env": { - "browser": true, - "mocha": true - }, - "parser": "babel-eslint", - rules: { - "babel/generator-star-spacing": 2, - "babel/new-cap": 2, - "babel/array-bracket-spacing": 2, - "babel/object-shorthand": 2, - "babel/flow-object-type": 2, - "babel/no-await-in-loop": 0, - "babel/arrow-parens": 0, - "import/no-unresolved": 0, - "no-underscore-dangle": 0, - "no-unused-expressions": 0, - "no-confusing-arrow": 0, - "array-callback-return": 0, - "consistent-return": 0, - "react/no-multi-comp": 0, - "dot-notation": [ - "error", { - "allowPattern": "^(default|public|private|return)$" - } - ] - } -} diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 00000000000..03793b89c61 --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,56 @@ +# GitHub Workflows + +This directory contains the GitHub Actions workflows that power continuous integration and end-to-end testing for Linode Cloud Manager. + +## Continuous Integration +The `ci` workflow handles testing, building, and publishing of packages in this repository. Tests are run using [Vitest](https://vitest.dev/) for `api-v4` and `manager`. + +If the continuous integration workflow was triggered via a push to the `master` branch, the built packages are published: + +* `api-v4` and `validation` are published to [npm](https://www.npmjs.com/) +* `manager` is published to [cloud.linode.com](https://cloud.linode.com) + +### Triggers +* Upon push to `master` branch +* Upon pull request creation + +### Secrets +| Name | Description | +|-----------------------|---------------------------------------------------| +| AWS_ACCESS_KEY_ID | AWS access key, or equivalent | +| AWS_S3_BUCKET | Name of S3 bucket where Cloud Manager is deployed | +| AWS_SECRET_ACCESS_KEY | AWS secret access key, or equivalent | +| NPM_AUTH_TOKEN | NPM authentication token for package publishing | +| SLACK_WEBHOOK | Webhook for Slack CI notifications | +| STORYBOOK_BUCKET | Name of S3 bucket where Storybook is deployed | + +## End-to-End Tests +Automatic end-to-end testing of Linode Cloud Manager via [Cypress](https://www.cypress.io/) is handled by the `Run Tests On PR` and `Run Tests On Push/Schedule` workflows. These two workflows are very similar, and differ primarily in how they are triggered. + +End-to-end tests are run automatically for the `develop` branch each weekday at 8:00 AM ET, and are triggered any time code is pushed to the `develop`, `staging`, and `master` branches. Tests also run for pull requests authored by Cloud Manager team members. + +Cypress tests are parallelized across four containers, and tests are automatically distributed among containers for optimal performance. To avoid race conditions, each test container is authenticated with its own test user account. + +### Triggers +* Scheduled, 1:00 PM UTC (8:00 AM ET) every Monday through Friday for `develop` branch +* Upon push to `develop`, `staging`, and `master` branches +* Upon creation or update to any pull request authored by a Cloud Manager team member + +### Secrets +| Name | Description | +|----------------------------|--------------------------------------------| +| USER_1 | Cloud Manager access token for test user 1 | +| USER_2 | Cloud Manager access token for test user 2 | +| USER_3 | Cloud Manager access token for test user 3 | +| USER_4 | Cloud Manager access token for test user 4 | +| REACT_APP_LAUNCH_DARKLY_ID | LaunchDarkly client ID | +| REACT_APP_CLIENT_ID | Linode OAuth app client ID | +| REACT_APP_API_ROOT | Linode API root URL | +| REACT_APP_APP_ROOT | Linode Cloud Manager instance root URL | + +## See Also +* [_Understanding GitHub Actions_](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions) (`docs.github.com`) +* [_Introduction to Cypress_](https://docs.cypress.io/guides/core-concepts/introduction-to-cypress) (`docs.cypress.io`) +* [Cypress: _GitHub Actions_](https://docs.cypress.io/guides/continuous-integration/github-actions#Cypress-GitHub-Action) (`docs.cypress.io`) +* [Cypress: _Parallelization_](https://docs.cypress.io/guides/guides/parallelization) (`docs.cypress.io`) +* [Vitest: _Getting Started_](https://vitest.dev/guide/) (`vitest.dev`) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000000..57a52f14260 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,458 @@ +name: ci + +permissions: + contents: read + +on: + push: + branches: + - master + - staging + - develop + pull_request: + +jobs: + lint: + strategy: + matrix: + package: + [ + "linode-manager", + "@linode/api-v4", + "@linode/queries", + "@linode/shared", + "@linode/ui", + "@linode/utilities", + "@linode/validation", + ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + with: + run_install: false + version: 10 + - uses: actions/setup-node@v4 + with: + node-version-file: "package.json" + cache: "pnpm" + - run: pnpm install --frozen-lockfile + - run: pnpm run --filter ${{ matrix.package }} lint + + build-validation: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + with: + run_install: false + version: 10 + - uses: actions/setup-node@v4 + with: + node-version-file: "package.json" + cache: "pnpm" + - run: pnpm install --frozen-lockfile + - run: pnpm run --filter @linode/validation build + - uses: actions/upload-artifact@v4 + with: + name: packages-validation-lib + path: packages/validation/lib + + test-sdk: + runs-on: ubuntu-latest + needs: build-validation + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + with: + run_install: false + version: 10 + - uses: actions/setup-node@v4 + with: + node-version-file: "package.json" + cache: "pnpm" + - run: pnpm install --frozen-lockfile + - uses: actions/download-artifact@v4 + with: + name: packages-validation-lib + path: packages/validation/lib + - run: pnpm run --filter @linode/api-v4 test + + build-sdk: + runs-on: ubuntu-latest + needs: build-validation + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + with: + run_install: false + version: 10 + - uses: actions/setup-node@v4 + with: + node-version-file: "package.json" + cache: "pnpm" + - uses: actions/download-artifact@v4 + with: + name: packages-validation-lib + path: packages/validation/lib + - run: pnpm install --frozen-lockfile + - run: pnpm run --filter @linode/api-v4 build + - uses: actions/upload-artifact@v4 + with: + name: packages-api-v4-lib + path: packages/api-v4/lib + + validate-sdk: + runs-on: ubuntu-latest + needs: build-sdk + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + with: + run_install: false + version: 10 + - uses: actions/setup-node@v4 + with: + node-version-file: "package.json" + cache: "pnpm" + - run: pnpm install --frozen-lockfile + + # Download the validation and api-v4 artifacts (built packages) + - uses: actions/download-artifact@v4 + with: + name: packages-validation-lib + path: packages/validation/lib + - uses: actions/download-artifact@v4 + with: + name: packages-api-v4-lib + path: packages/api-v4/lib + + # Create an api-v4 tarball + - run: cd packages/api-v4 && pnpm pack --pack-destination ../../ + + # Create an validation tarball + - run: cd packages/validation && pnpm pack --pack-destination ../../ + + # Test @linode/api-v4 as an ES Module + - run: mkdir test-sdk-esm && cd test-sdk-esm && npm init es6 -y && npm install ../$(ls ../ | grep "linode-api-v4-.*\.tgz") ../$(ls ../ | grep "linode-validation-.*\.tgz") + - run: cp scripts/validatePackages/sdk-esm.js test-sdk-esm/ + - run: cd test-sdk-esm && node ./sdk-esm.js + + # Verify @linode/api-v4 as CommonJS + - run: mkdir test-sdk-cjs && cd test-sdk-cjs && npm init -y && npm install ../$(ls ../ | grep "linode-api-v4-.*\.tgz") ../$(ls ../ | grep "linode-validation-.*\.tgz") + - run: cp scripts/validatePackages/sdk-commonjs.cjs test-sdk-cjs/ + - run: cd test-sdk-cjs && node ./sdk-commonjs.cjs + + test-manager: + runs-on: ubuntu-latest + needs: build-sdk + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + with: + run_install: false + version: 10 + - uses: actions/setup-node@v4 + with: + node-version-file: "package.json" + cache: "pnpm" + - uses: actions/download-artifact@v4 + with: + name: packages-validation-lib + path: packages/validation/lib + - uses: actions/download-artifact@v4 + with: + name: packages-api-v4-lib + path: packages/api-v4/lib + - run: pnpm install --frozen-lockfile + - run: pnpm run --filter linode-manager test + + test-search: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + with: + run_install: false + version: 10 + - uses: actions/setup-node@v4 + with: + node-version-file: "package.json" + cache: "pnpm" + - run: pnpm install --frozen-lockfile + - run: pnpm run --filter @linode/search test + + test-ui: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + with: + run_install: false + version: 10 + - uses: actions/setup-node@v4 + with: + node-version-file: "package.json" + cache: "pnpm" + - run: pnpm install --frozen-lockfile + - run: pnpm run --filter @linode/ui test + + test-utilities: + needs: build-sdk + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + with: + run_install: false + version: 10 + - uses: actions/setup-node@v4 + with: + node-version-file: "package.json" + cache: "pnpm" + - uses: actions/download-artifact@v4 + with: + name: packages-api-v4-lib + path: packages/api-v4/lib + - run: pnpm install --frozen-lockfile + - run: pnpm run --filter @linode/utilities test + + test-queries: + runs-on: ubuntu-latest + needs: build-sdk + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + with: + run_install: false + version: 10 + - uses: actions/setup-node@v4 + with: + node-version-file: "package.json" + cache: "pnpm" + - uses: actions/download-artifact@v4 + with: + name: packages-api-v4-lib + path: packages/api-v4/lib + - run: pnpm install --frozen-lockfile + - run: pnpm run --filter @linode/queries test + + test-shared: + runs-on: ubuntu-latest + needs: build-sdk + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + with: + run_install: false + version: 10 + - uses: actions/setup-node@v4 + with: + node-version-file: "package.json" + cache: "pnpm" + - uses: actions/download-artifact@v4 + with: + name: packages-api-v4-lib + path: packages/api-v4/lib + - uses: actions/download-artifact@v4 + with: + name: packages-validation-lib + path: packages/validation/lib + - run: pnpm install --frozen-lockfile + - run: pnpm run --filter @linode/shared test + + typecheck-ui: + runs-on: ubuntu-latest + needs: build-sdk + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + with: + run_install: false + version: 10 + - uses: actions/setup-node@v4 + with: + node-version-file: "package.json" + cache: "pnpm" + - run: pnpm install --frozen-lockfile + - run: pnpm run --filter @linode/ui typecheck + + typecheck-utilities: + runs-on: ubuntu-latest + needs: build-sdk + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + with: + run_install: false + version: 10 + - uses: actions/setup-node@v4 + with: + node-version-file: "package.json" + cache: "pnpm" + - uses: actions/download-artifact@v4 + with: + name: packages-api-v4-lib + path: packages/api-v4/lib + - run: pnpm install --frozen-lockfile + - run: pnpm run --filter @linode/utilities typecheck + + typecheck-queries: + runs-on: ubuntu-latest + needs: build-sdk + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + with: + run_install: false + version: 10 + - uses: actions/setup-node@v4 + with: + node-version-file: "package.json" + cache: "pnpm" + - uses: actions/download-artifact@v4 + with: + name: packages-api-v4-lib + path: packages/api-v4/lib + - run: pnpm install --frozen-lockfile + - run: pnpm run --filter @linode/queries typecheck + + typecheck-shared: + runs-on: ubuntu-latest + needs: build-sdk + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + with: + run_install: false + version: 10 + - uses: actions/setup-node@v4 + with: + node-version-file: "package.json" + cache: "pnpm" + - uses: actions/download-artifact@v4 + with: + name: packages-api-v4-lib + path: packages/api-v4/lib + - uses: actions/download-artifact@v4 + with: + name: packages-validation-lib + path: packages/validation/lib + - run: pnpm install --frozen-lockfile + - run: pnpm run --filter @linode/shared typecheck + + typecheck-manager: + runs-on: ubuntu-latest + needs: build-sdk + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + with: + run_install: false + version: 10 + - uses: actions/setup-node@v4 + with: + node-version-file: "package.json" + cache: "pnpm" + - uses: actions/download-artifact@v4 + with: + name: packages-validation-lib + path: packages/validation/lib + - uses: actions/download-artifact@v4 + with: + name: packages-api-v4-lib + path: packages/api-v4/lib + - run: pnpm install --frozen-lockfile + - run: pnpm run --filter linode-manager typecheck + + publish-packages: + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/master' + needs: + - build-sdk + - build-validation + - test-sdk + - validate-sdk + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + with: + run_install: false + version: 10 + - uses: actions/setup-node@v4 + with: + node-version-file: "package.json" + cache: "pnpm" + - uses: actions/download-artifact@v4 + with: + name: packages-api-v4-lib + path: packages/api-v4/lib + - uses: actions/download-artifact@v4 + with: + name: packages-validation-lib + path: packages/validation/lib + - run: pnpm install --frozen-lockfile + - run: npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} + env: + NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} + - run: pnpm publish -r --filter @linode/api-v4 --filter @linode/validation --no-git-checks --access public + - name: slack-notify + uses: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661 # v2.3.3 + env: + SLACK_CHANNEL: api-js-client + SLACK_TITLE: "Packages published" + SLACK_MESSAGE: ":rocket: Linode packages have been published!" + SLACK_USERNAME: npm-bot + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_ICON_EMOJI: ":package:" + + build-storybook: + runs-on: ubuntu-latest + needs: build-sdk + env: + NODE_OPTIONS: --max-old-space-size=4096 + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + with: + run_install: false + version: 10 + - uses: actions/setup-node@v4 + with: + node-version-file: "package.json" + cache: "pnpm" + - uses: actions/download-artifact@v4 + with: + name: packages-validation-lib + path: packages/validation/lib + - uses: actions/download-artifact@v4 + with: + name: packages-api-v4-lib + path: packages/api-v4/lib + - run: pnpm install --frozen-lockfile + - run: pnpm run --filter linode-manager build-storybook + - uses: actions/upload-artifact@v4 + with: + name: storybook-build + path: packages/manager/storybook-static + + publish-storybook: + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/master' + needs: build-storybook + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: + name: storybook-build + path: storybook/build + - uses: jakejarvis/s3-sync-action@be0c4ab89158cac4278689ebedd8407dd5f35a83 # v0.5.1 + with: + args: --acl public-read --follow-symlinks --delete + env: + AWS_S3_ENDPOINT: https://us-east-1.linodeobjects.com + AWS_S3_BUCKET: ${{ secrets.STORYBOOK_BUCKET }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_REGION: us-east-1 + SOURCE_DIR: storybook/build diff --git a/.github/workflows/coverage_badge.yml b/.github/workflows/coverage_badge.yml new file mode 100644 index 00000000000..44d5902256d --- /dev/null +++ b/.github/workflows/coverage_badge.yml @@ -0,0 +1,57 @@ +name: Coverage Badge + +permissions: + contents: read + +on: + push: + branches: + - master + +jobs: + generate-coverage-badge: + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + with: + run_install: false + version: 10 + + - uses: actions/setup-node@v4 + with: + node-version-file: "package.json" + cache: "pnpm" + + - name: Install Dependencies + run: pnpm install --frozen-lockfile + + - name: Build @linode/validation + run: pnpm build:validation + + - name: Build @linode/api-v4 + run: pnpm build:sdk + + - name: Run Base Branch Coverage + run: pnpm coverage:summary + + - name: Generate Coverage Badge + uses: jaywcjlove/coverage-badges-cli@7f0781807ef3e7aba97a145beca881d36451b7b7 # v1.1.1 + with: + label: "@linode/manager coverage" + source: ./packages/manager/coverage/coverage-summary.json + output: ./packages/manager/coverage/badges.svg + + - uses: jakejarvis/s3-sync-action@7ed8b112447abb09f1da74f3466e4194fc7a6311 # v0.5.1 + with: + args: --acl public-read --follow-symlinks --delete + env: + AWS_S3_ENDPOINT: https://us-east-1.linodeobjects.com + AWS_S3_BUCKET: ${{ secrets.COVERAGE_BUCKET }} + AWS_ACCESS_KEY_ID: ${{ secrets.COVERAGE_BUCKET_ACCESS }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.COVERAGE_BUCKET_SECRET }} + AWS_REGION: us-east-1 + SOURCE_DIR: ./packages/manager/coverage diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 00000000000..a0466e3b1b6 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,43 @@ +name: Deploy Cloud Manager Docs + +on: + push: + branches: [develop] + +permissions: + pages: write + id-token: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Pages + uses: actions/configure-pages@v5 + + - uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2 + with: + bun-version: 1.0.21 + + - name: Build with VitePress + run: bunx vitepress@1.0.0-rc.35 build docs + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: docs/.vitepress/dist + + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + needs: build + runs-on: ubuntu-latest + name: Deploy + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/e2e_schedule_and_push.yml b/.github/workflows/e2e_schedule_and_push.yml new file mode 100644 index 00000000000..bf66d7cd3eb --- /dev/null +++ b/.github/workflows/e2e_schedule_and_push.yml @@ -0,0 +1,72 @@ +name: Run Tests On Push/Schedule +concurrency: UI_TESTS + +permissions: + contents: read + +env: + USER_1: ${{ secrets.USER_1 }} + USER_2: ${{ secrets.USER_2 }} + USER_3: ${{ secrets.USER_3 }} + USER_4: ${{ secrets.USER_4 }} + CLIENT_ID: ${{ secrets.REACT_APP_CLIENT_ID }} + CY_TEST_FAIL_ON_MANAGED: 1 + CY_TEST_RESET_PREFERENCES: 1 + CY_TEST_SPLIT_RUN: 1 + CY_TEST_SPLIT_RUN_TOTAL: 4 +on: + schedule: + - cron: "0 13 * * 1-5" + push: + branches: + - develop + - staging + - master + +jobs: + run-cypress-e2e: + name: Cypress Tests (User ${{ matrix.user.index }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + user: + - { index: 1, name: "USER_1" } + - { index: 2, name: "USER_2" } + - { index: 3, name: "USER_3" } + - { index: 4, name: "USER_4" } + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + with: + run_install: false + version: 10 + - uses: actions/setup-node@v4 + with: + node-version-file: "package.json" + - run: | + echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV + - run: | + echo "REACT_APP_LAUNCH_DARKLY_ID=${{ secrets.REACT_APP_LAUNCH_DARKLY_ID }}" >> ./packages/manager/.env + echo "REACT_APP_CLIENT_ID=$CLIENT_ID" >> ./packages/manager/.env + echo "REACT_APP_LOGIN_ROOT=${{ secrets.REACT_APP_LOGIN_ROOT }}" >> ./packages/manager/.env + echo "REACT_APP_API_ROOT=${{ secrets.REACT_APP_API_ROOT }}" >> ./packages/manager/.env + echo "REACT_APP_APP_ROOT=${{ secrets.REACT_APP_APP_ROOT }}" >> ./packages/manager/.env + echo "REACT_APP_DISABLE_NEW_RELIC=1" >> ./packages/manager/.env + echo "MANAGER_OAUTH=${{ env[matrix.user.name] }}" >> ./packages/manager/.env + echo "CY_TEST_SPLIT_RUN_INDEX=${{ matrix.user.index }}" >> ./packages/manager/.env + - run: pnpm install --frozen-lockfile + - run: pnpm run --filter @linode/validation build + - run: pnpm run --filter @linode/api-v4 build + - name: Run tests + uses: cypress-io/github-action@b8ba51a856ba5f4c15cf39007636d4ab04f23e3c # v6.10.2 + with: + working-directory: packages/manager + wait-on: "http://localhost:3000" + wait-on-timeout: 1000 + install: false + build: pnpm run build + start: pnpm start:ci + browser: chrome + record: false + parallel: false diff --git a/.github/workflows/eslint_review.yml b/.github/workflows/eslint_review.yml new file mode 100644 index 00000000000..cb1424cd786 --- /dev/null +++ b/.github/workflows/eslint_review.yml @@ -0,0 +1,30 @@ +name: ESLint Review +on: [pull_request] +jobs: + eslint: + name: ESLint Review + runs-on: ubuntu-latest + permissions: + contents: read + checks: write + strategy: + matrix: + package: [manager, api-v4, queries, shared, ui, utilities, validation] + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@eae0cfeb286e66ffb5155f1a79b90583a127a68b # v2.4.1 + with: + run_install: false + version: 10 + - uses: actions/setup-node@v4 + with: + node-version-file: "package.json" + cache: "pnpm" + - run: pnpm install + - uses: abailly-akamai/action-eslint@8ad68ba04fa60924ef7607b07deb5989f38f5ed6 # v1.0.2 + with: + workdir: packages/${{ matrix.package }} + github_token: ${{ secrets.GITHUB_TOKEN }} + reporter: github-pr-check + level: warning # This will report both warnings and errors + filter_mode: added # Only comment on new/modified lines diff --git a/.github/workflows/security_scan.yml b/.github/workflows/security_scan.yml new file mode 100644 index 00000000000..2b835cd894e --- /dev/null +++ b/.github/workflows/security_scan.yml @@ -0,0 +1,36 @@ +# Perform Static Application Security Testing (SAST) scanning on Cloud Manager. +name: Security Scan + +permissions: + contents: read + +on: + push: + branches: + - develop + +jobs: + security-scan: + runs-on: ubuntu-latest + container: + image: returntocorp/semgrep + steps: + - uses: actions/checkout@v4 + + # Perform scanning using Semgrep + # Pass even when it identifies issues or encounters errors. + - name: Run SAST scan + if: always() + run: semgrep ci || true + env: + SEMGREP_RULES: p/default + + # Post results to Slack notification channel. + - name: slack-notify + uses: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661 # v2.3.3 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_SAST_WEBHOOK }} + SLACK_MESSAGE: "Message: ${{ github.event.head_commit.message }} \nRepository: ${{ github.event.repository.url }}" + SLACK_COLOR: ${{ job.status }} + SLACK_FOOTER: "" + MSG_MINIMAL: event,actions url,commit diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 00000000000..fc547c25c70 --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,25 @@ +name: 'Stale issue handler' + +permissions: + pull-requests: write + +on: + workflow_dispatch: null + schedule: + - cron: '0 0 * * *' + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v9 + id: stale + with: + stale-pr-message: 'This PR is stale because it has been open 15 days with + no activity. Please attend to this PR or it will be closed in + 5 days' + days-before-stale: 15 + days-before-close: 5 + # Disable issues. We only want this running on PRs. + days-before-issue-stale: -1 + days-before-issue-close: -1 diff --git a/.gitignore b/.gitignore index c0ea7086227..ebd28879c45 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,146 @@ -.DS_Store -node_modules -npm-debug.log +# production dist -src/secrets.js -xunit.xml +build +lib +**/api-v4/index.js +**/api-v4/index.node.js +**/api-v4/index.d.ts +**/validation/index.js +**/validation/index.d.ts + +# editor configuration +.vscode +.cursor +.idea +**/*.iml +*.mdc + +# misc +.DS_Store + +# swc data +.swc + +# local restart script with keys +restart.sh + +# dotenv environment variables file +.env* +*env. + +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Test results +junit.xml + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul coverage -.sass-cache/ + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Typescript v1 declaration files +typings/ +tsconfig.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + +# next.js build output +.next + +# custom files +restart-manager.sh +makefile + +# E2E Test Temporary Files +**/e2e/errorShots/*.png +**/e2e/test-results/*.xml +localStorage.json +**/e2e/drivers +**/storybook-test-results/*.xml +.tmp*.status +**/e2e/creds.js + +# storybook static files +.out +packages/manager/storybook-static/ + +# Vim users +*.swp + +#sonar +.scannerwork +.sonar +packages/manager/test-report.xml + +# cypress files/folders +**/manager/config/development.json +**/manager/config/staging.json +**/manager/cypress/videos/ +**/manager/cypress/downloads/ +**/manager/cypress/results/ +**/manager/cypress/screenshots/ +**/manager/cypress/reports/ + +packages/manager/cypress/fixtures/example.json + +nohup.out +packages/manager/bundle_analyzer_report.html + +**/manager/src/dev-tools/*.local.* + +# vitepress +docs/.vitepress/cache + +# pnpm store will be generated if you run pnpm install in docker environments +.pnpm-store diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 00000000000..e02c24e2b5c --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +pnpm lint-staged \ No newline at end of file diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000000..6e77d0a7496 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +22.19 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 27c1fd1b738..00000000000 --- a/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -language: node_js -node_js: - - "6" -script: - - | - cat < src/secrets.js - export const clientId = 'placeholder'; - export const clientSecret = 'placeholder'; - EOF - - npm test - - cat ./coverage/lcov.info | ./node_modules/.bin/coveralls - - npm run lint diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000000..767d587be17 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,8 @@ +# Change Log + +This changelog has been deprecated in favor individual changelogs for each package. + +See changelogs for: +- [@linode/api-v4](https://github.com/linode/manager/blob/master/packages/api-v4/CHANGELOG.md) +- [@linode/manager](https://github.com/linode/manager/blob/master/packages/manager/CHANGELOG.md) +- [@linode/validation](https://github.com/linode/manager/blob/master/packages/validation/CHANGELOG.md) \ No newline at end of file diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 00000000000..b5eef9f001a --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,50 @@ +# Default Team +# This is a catch all: any change that is not captured by a codeowner rule +# below will result in`@linode/cloud-manager-code-reviewers` being assigned +# for PR review. +* @linode/cloud-manager-code-reviewers + +# Cypress E2E Tests +# This is also a catch all: any change to E2E tests outside of the team-owned +# files and directories will result in `@linode/frontend-sdet` being assigned +# for PR review. +/packages/manager/cypress/ @linode/frontend-sdet + +# UI Package +/packages/ui @linode/ui-platform-design-systems + +# Metrics & Alerts +/packages/api-v4/src/cloudpulse @linode/metrics-alerts +/packages/validation/src/cloudpulse.schema.ts @linode/metrics-alerts +/packages/manager/cypress/e2e/core/cloudpulse @linode/metrics-alerts +/packages/manager/cypress/support/util/cloudpulse.ts @linode/metrics-alerts +/packages/manager/cypress/support/constants/cloudpulse.ts @linode/metrics-alerts +/packages/manager/cypress/support/intercepts/cloudpulse.ts @linode/metrics-alerts +/packages/manager/src/routes/alerts @linode/metrics-alerts +/packages/manager/src/routes/metrics @linode/metrics-alerts +/packages/manager/src/factories/cloudpulse @linode/metrics-alerts +/packages/manager/src/features/CloudPulse @linode/metrics-alerts +/packages/manager/src/queries/cloudpulse @linode/metrics-alerts + +# IAM +/packages/api-v4/src/iam @linode/iam +/packages/manager/src/routes/IAM @linode/iam +/packages/manager/cypress/component/features/IAM @linode/iam +/packages/queries/src/iam @linode/iam +/packages/manager/src/features/IAM @linode/iam +/packages/manager/src/mocks/presets/crud/seeds/delegation.ts @linode/iam +/packages/manager/src/mocks/presets/crud/handlers/delegation.ts @linode/iam +/packages/manager/src/mocks/presets/crud/delegation.ts @linode/iam +/packages/utilities/src/factories/delegation.ts @linode/iam + +# DBaaS +/packages/manager/src/features/Databases @linode/dbaas-ui +/packages/manager/src/routes/databases @linode/dbaas-ui +/packages/manager/src/queries/databases @linode/dbaas-ui +/packages/manager/src/factories/databases.ts @linode/dbaas-ui +/packages/queries/src/databases @linode/dbaas-ui +/packages/api-v4/src/databases @linode/dbaas-ui +/packages/validation/src/databases.schema.ts @linode/dbaas-ui +/packages/manager/cypress/e2e/core/databases @linode/dbaas-ui +/packages/manager/cypress/support/constants/databases.ts @linode/dbaas-ui +/packages/manager/cypress/support/intercepts/databases.ts @linode/dbaas-ui diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 80ea0886f3e..00000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,74 +0,0 @@ -# Contributing to the Linode manager - -Contributing just involves sending a pull request. You will probably be more -successful with your contribution if you visit the [IRC -channel](https://webchat.oftc.net/?channels=linode-next&uio=d4) upfront and discuss -your plans. - -## Development Flow - -Changes to the Linode Manager usually follow this flow: - -1. If required, make a mockup -1. Review and approve the mockup with peers (and sometimes stakeholders) -1. Implement the change, with tests -1. Merge the change - -This usually implicates two GitHub issues: the design issue, and the -implementation issue. For some changes, a design issue is of course not always -necessary. - -We label issues as "ready" when one of our developers has committed to -resolving it during the current 1-2 week sprint. You're welcome to take these on -if you want, but we might finish it first. We merge pull requests on a -first-come-first-serve basis; the first PR that adequately solves the problem -will be merged. - -## Making design changes - -If a mockup is necessary for your change, find the relevant GitHub issue or open -one yourself if it's not there. Our design repository is -[manager-design](https://github.com/linode/manager-design) and contains Sketch -files for our mockups. Base yours off of what we have here, then comment on the -GitHub issue with screenshots for discussion. - -## Making pull requests - -If you already have your own pull request habits, feel free to use them. If you -don't, however, allow me to make a suggestion: feature branches pulled from -upstream. Try this: - -1. Fork manager -1. Clone your fork -1. git remote add upstream git://github.com/Linode/manager.git - -You only need to do this once. You're never going to use your fork's master -branch. Instead, when you start working on a feature, do this: - -1. git fetch upstream -1. git checkout -b add-so-and-so-feature upstream/master -1. work -1. git push -u origin add-so-and-so-feature -1. Run `npm run lint` to lint your code and `npm test` to test your code -1. Make pull request from your feature branch - -**Tip**: automatically lint your commits by running this snippet: - - printf '%s\n%s' '#!/usr/bin/env bash' 'npm run lint' > .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit - -### Coding Style - -The manager is written in ES6, with some ES7 in use as well. A general guideline -for the coding style is "imitate the code that's already there". If in doubt, -apply the [Airbnb style guide](https://github.com/airbnb/javascript). - -## Reporting Bugs - -First, remember that this is a work in progress. Please don't report bugs for -features that aren't present, links that lead to 404's, buttons that don't -appear to do anything - these are all likely in-progress or not started -features. Instead, report bugs for regressions or problems with things that are -already implemented. Please search the GitHub issues to see if there's already a -bug filed for your problem - if so, leave a comment mentioning that you can -reproduce it. Otherwise, go ahead and open an issue with as much detail as you -can provide. Thanks! diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000000..a26adb5e173 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,3 @@ +library 'ui-builder' + +buildManager() diff --git a/Jenkinsfile-component-tests.groovy b/Jenkinsfile-component-tests.groovy new file mode 100644 index 00000000000..90ce63039e7 --- /dev/null +++ b/Jenkinsfile-component-tests.groovy @@ -0,0 +1,3 @@ +library 'ui-builder' + +testManagerComponents() diff --git a/Jenkinsfile-playwright.groovy b/Jenkinsfile-playwright.groovy new file mode 100644 index 00000000000..4a7b5369ac6 --- /dev/null +++ b/Jenkinsfile-playwright.groovy @@ -0,0 +1,3 @@ +library 'cloud-manager-ui-tests' + +runTestsRelease() diff --git a/Jenkinsfile-tests.groovy b/Jenkinsfile-tests.groovy new file mode 100644 index 00000000000..b2e1dd37f18 --- /dev/null +++ b/Jenkinsfile-tests.groovy @@ -0,0 +1,3 @@ +library 'ui-builder' + +testManager() diff --git a/LICENSE b/LICENSE index de88251165a..5af40cff839 100644 --- a/LICENSE +++ b/LICENSE @@ -1,39 +1,201 @@ -The following license only applies to source code, defined as any text file -in this repository, not including vector graphics: - - Copyright (c) 2016, Linode, LLC - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. Neither the name of the copyright holder nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -Other assets (files containing raster and vector graphics) are the proprietary -property of Linode, LLC, and may not be used outside of the context of this -project for any purpose without prior written approval from Linode, LLC. - -Some files or assets in this repository are not the intellectual property of -Linode and are included under the terms of the licenses of the owners of that -content. In such cases, such content is accompanied by a LICENSE file in the -same directory explaining the license terms of that content. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2019 Akamai Technologies, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/README.md b/README.md index bbf7328abab..991b48cfd68 100644 --- a/README.md +++ b/README.md @@ -1,98 +1,66 @@ -

- +

+
- The Linode Manager -

+
+ Akamai Connected Cloud Manager +

- Build status - Code coverage - Dependency Status - Sprint status - much badges + Linode Manager Code Coverage

-This is the new Linode Manager. It provides a web interface for managing your -Linode account. Currently this software is *pre-alpha* and won't be released for -a while. [Read the blog post](https://engineering.linode.com/2016/05/16/Announcing-the-new-open-source-manager.html). - -The following buzzwords are involved in this project: - -* [React.js](https://facebook.github.io/react/) -* [Redux](http://redux.js.org/) -* [Webpack](https://webpack.github.io/) -* ES6/ES7 (via [Babel](https://babeljs.io/)) -* [SCSS](http://sass-lang.com) - -## Setup - - git clone https://github.com/Linode/manager.git - cd manager - node --version # should be 6.x or better - npm install - -Currently the codebase is hardcoded to point to our [alpha -environment](https://alpha.linode.com). It communicates with Linode via -[Linode API 4](https://developers.linode.com). You'll need to [register an OAuth -client](https://developers.linode.com/reference/#authentication) in the alpha -environment, then create a file at `src/secrets.js` with your client ID and -client secret set appropriately: - - export const clientId = 'change me'; - export const clientSecret = 'change me'; - -Be sure to set your callback URL to something like -`http://localhost:3000/oauth/callback` when you register your OAuth client. - -Note: if you pick a callback url that is not on localhost:3000, you will need to -update the APP_ROOT variable in src/constants.js to point to the different -server. - -## Development - -Run: - - npm start - -to start the development server. Connect to -[localhost:3000](https://localhost:3000) to try it out. Most of the changes you -make will be applied on the fly, but you may occasionally find that you have to -restart it. - -While running the manager in development mode, you may press Ctrl+H to view the -redux dev tools to track the state of the application, and Ctrl+Q to move them -around the screen if necessary. - -## Tests - -To run tests: +

+ + CI Build Stats on develop + + + Website + + + Cloud Manager Version + + + Storybook + +

+

+ + @linode/api-v4 version + + + api-v4 bundle size + + + @linode/validation version + + + validation bundle size + + +

- npm test +## Overview -To automatically re-run tests when you make changes: +This repository is home to the Akamai Connected **[Cloud Manager](https://cloud.linode.com)** and related Typescript packages: +- [`@linode/api-v4`](packages/api-v4/) +- [`@linode/queries`](packages/queries/) +- [`@linode/search`](packages/search/) +- [`@linode/shared`](packages/shared/) +- [`@linode/ui`](packages/ui/) +- [`@linode/utilities`](packages/utilities/) +- [`@linode/validation`](packages/validation/) - npm run test:watch +## Developing Locally -Our tests live in test/**.spec.js. They're based on -[Mocha](https://mochajs.org/) and do assertions with -[Chai](http://chaijs.com/) plus DOM/React testing with -[enzyme](http://airbnb.io/enzyme/). We run them with -[Karma](https://news.ycombinator.com/item?id=11927891). -We're aiming for 95%+ test coverage. +To get started running Cloud Manager locally, please see the [Getting Started guide](https://linode.github.io/manager/GETTING_STARTED.html). ## Contributing -Come chat with us in [#linode-next on -irc.oftc.net](https://webchat.oftc.net/?channels=linode-next&uio=d4) if you're -interested in helping out with this. We'd love to have community input on how -the new manager takes shape. This is your chance to help build the features you -need into it! We'll take pull requests in the usual way. We're still learning -about the technologies in use here ourselves, so bear with us as we figure out -the right patterns - some large scale refactorings may be in order. +If you already have your development environment set up, please read the [Contributing Guidelines](https://linode.github.io/manager/CONTRIBUTING.html) to get help in creating your first Pull Request. + +To report a bug or request a feature in Cloud Manager, please [open a GitHub Issue](https://github.com/linode/manager/issues/new). For general feedback, use [linode.com/feedback](https://www.linode.com/feedback/). ## License -The Linode Manager's code is distributed under the terms of the [BSD 3-clause -license](https://github.com/linode/manager/blob/master/LICENSE). The assets are -not licensed for any purpose without prior written approval from Linode, unless -otherwise noted. +All code located in this repository is distributed under the terms of the [APLv2 +license](LICENSE). diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000000..0a8bb822749 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,25 @@ +# Akamai uses HackerOne for responsible disclosure using separate, invite-only programs for specific scopes + +## Akamai CDN + + + +## Akamai Connected Cloud / Linode + + + +Policy: + +## In addition, we welcome _all_ types of security reports via email + +Contact: mailto:security@akamai.com + +Encryption: + +## Please send abuse reports to + +Contact: mailto:abuse@akamai.com + +Hiring: + +Preferred-Languages: en diff --git a/assets/distros/Arch.png b/assets/distros/Arch.png deleted file mode 100644 index 8e2b4ac0b00..00000000000 Binary files a/assets/distros/Arch.png and /dev/null differ diff --git a/assets/distros/CentOS.png b/assets/distros/CentOS.png deleted file mode 100644 index e7bf5b10aa5..00000000000 Binary files a/assets/distros/CentOS.png and /dev/null differ diff --git a/assets/distros/Debian.png b/assets/distros/Debian.png deleted file mode 100644 index c0ee62ef9ce..00000000000 Binary files a/assets/distros/Debian.png and /dev/null differ diff --git a/assets/distros/Fedora.png b/assets/distros/Fedora.png deleted file mode 100644 index d63e61a27f5..00000000000 Binary files a/assets/distros/Fedora.png and /dev/null differ diff --git a/assets/distros/Gentoo.png b/assets/distros/Gentoo.png deleted file mode 100644 index fa75b52f5c6..00000000000 Binary files a/assets/distros/Gentoo.png and /dev/null differ diff --git a/assets/distros/OpenSUSE.png b/assets/distros/OpenSUSE.png deleted file mode 100644 index 5fa7fac7a5a..00000000000 Binary files a/assets/distros/OpenSUSE.png and /dev/null differ diff --git a/assets/distros/Slackware.png b/assets/distros/Slackware.png deleted file mode 100644 index e817534a984..00000000000 Binary files a/assets/distros/Slackware.png and /dev/null differ diff --git a/assets/distros/Ubuntu.png b/assets/distros/Ubuntu.png deleted file mode 100644 index 7484308cc87..00000000000 Binary files a/assets/distros/Ubuntu.png and /dev/null differ diff --git a/assets/fonts/heebo/Heebo-Light.ttf b/assets/fonts/heebo/Heebo-Light.ttf deleted file mode 100644 index 8e4eee30050..00000000000 Binary files a/assets/fonts/heebo/Heebo-Light.ttf and /dev/null differ diff --git a/assets/fonts/heebo/Heebo-Regular.ttf b/assets/fonts/heebo/Heebo-Regular.ttf deleted file mode 100644 index b9d8e814226..00000000000 Binary files a/assets/fonts/heebo/Heebo-Regular.ttf and /dev/null differ diff --git a/assets/fonts/heebo/Heebo-Thin.ttf b/assets/fonts/heebo/Heebo-Thin.ttf deleted file mode 100644 index b901d1152a8..00000000000 Binary files a/assets/fonts/heebo/Heebo-Thin.ttf and /dev/null differ diff --git a/assets/fonts/heebo/OFL.txt b/assets/fonts/heebo/OFL.txt deleted file mode 100644 index 3f8cf1cf652..00000000000 --- a/assets/fonts/heebo/OFL.txt +++ /dev/null @@ -1,92 +0,0 @@ -Copyright 2014 The Heebo Project Authors. -This Font Software is licensed under the SIL Open Font License, Version 1.1. -This license is copied below, and is also available with a FAQ at: -http://scripts.sil.org/OFL - - ------------------------------------------------------------ -SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 ------------------------------------------------------------ - -PREAMBLE -The goals of the Open Font License (OFL) are to stimulate worldwide -development of collaborative font projects, to support the font creation -efforts of academic and linguistic communities, and to provide a free and -open framework in which fonts may be shared and improved in partnership -with others. - -The OFL allows the licensed fonts to be used, studied, modified and -redistributed freely as long as they are not sold by themselves. The -fonts, including any derivative works, can be bundled, embedded, -redistributed and/or sold with any software provided that any reserved -names are not used by derivative works. The fonts and derivatives, -however, cannot be released under any other type of license. The -requirement for fonts to remain under this license does not apply -to any document created using the fonts or their derivatives. - -DEFINITIONS -"Font Software" refers to the set of files released by the Copyright -Holder(s) under this license and clearly marked as such. This may -include source files, build scripts and documentation. - -"Reserved Font Name" refers to any names specified as such after the -copyright statement(s). - -"Original Version" refers to the collection of Font Software components as -distributed by the Copyright Holder(s). - -"Modified Version" refers to any derivative made by adding to, deleting, -or substituting -- in part or in whole -- any of the components of the -Original Version, by changing formats or by porting the Font Software to a -new environment. - -"Author" refers to any designer, engineer, programmer, technical -writer or other person who contributed to the Font Software. - -PERMISSION & CONDITIONS -Permission is hereby granted, free of charge, to any person obtaining -a copy of the Font Software, to use, study, copy, merge, embed, modify, -redistribute, and sell modified and unmodified copies of the Font -Software, subject to the following conditions: - -1) Neither the Font Software nor any of its individual components, -in Original or Modified Versions, may be sold by itself. - -2) Original or Modified Versions of the Font Software may be bundled, -redistributed and/or sold with any software, provided that each copy -contains the above copyright notice and this license. These can be -included either as stand-alone text files, human-readable headers or -in the appropriate machine-readable metadata fields within text or -binary files as long as those fields can be easily viewed by the user. - -3) No Modified Version of the Font Software may use the Reserved Font -Name(s) unless explicit written permission is granted by the corresponding -Copyright Holder. This restriction only applies to the primary font name as -presented to the users. - -4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font -Software shall not be used to promote, endorse or advertise any -Modified Version, except to acknowledge the contribution(s) of the -Copyright Holder(s) and the Author(s) or with their explicit written -permission. - -5) The Font Software, modified or unmodified, in part or in whole, -must be distributed entirely under this license, and must not be -distributed under any other license. The requirement for fonts to -remain under this license does not apply to any document created -using the Font Software. - -TERMINATION -This license becomes null and void if any of the above conditions are -not met. - -DISCLAIMER -THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE -COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL -DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM -OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/assets/linode-logo.svg b/assets/linode-logo.svg deleted file mode 100644 index 21298c905fd..00000000000 --- a/assets/linode-logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/devServer.js b/devServer.js deleted file mode 100644 index bd1691ba87c..00000000000 --- a/devServer.js +++ /dev/null @@ -1,35 +0,0 @@ -var path = require('path'); -var express = require('express'); -var webpack = require('webpack'); -var config = require('./webpack.config.dev'); -var mime = require('mime'); - -express.static.mime.define({ - 'application/x-font-ttf': ['ttf'], - 'application/font-ttf': ['ttf'] -}); - -var app = express(); -var compiler = webpack(config); - -app.use('/assets', express.static('assets')); - -app.use(require('webpack-dev-middleware')(compiler, { - noInfo: true, - publicPath: config.output.publicPath -})); - -app.use(require('webpack-hot-middleware')(compiler)); - -app.get('*', function(req, res) { - res.sendFile(path.join(__dirname, 'index.html')); -}); - -app.listen(3000, 'localhost', function(err) { - if (err) { - console.log(err); - return; - } - - console.log('Listening at http://localhost:3000'); -}); diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000000..5376d075f2e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,218 @@ +--- + +# Environment variables that will be exposed to every Cypress runner. +x-e2e-env: + &default-env + + # CI build information for Cypress Dashboard. + BUILD_ID: "${GIT_BRANCH}-${BUILD_NUMBER}" + BUILD_NUMBER: ${BUILD_NUMBER} + BUILD_URL: ${BUILD_URL} + + # Exposing `COMMIT_INFO_*` environment variables to Cypress allows us to + # manually specify git commit information. This is required because Cypress + # cannot retrieve the information automatically from within the container due + # to file ownership differences. + # + # See also: + # - https://github.com/cypress-io/commit-info + # - https://github.blog/2022-04-18-highlights-from-git-2-36/#stricter-repository-ownership-checks + COMMIT_INFO_AUTHOR: ${COMMIT_INFO_AUTHOR} + COMMIT_INFO_BRANCH: ${CHANGE_BRANCH} + COMMIT_INFO_EMAIL: ${COMMIT_INFO_EMAIL} + COMMIT_INFO_MESSAGE: ${COMMIT_INFO_MESSAGE} + COMMIT_INFO_REMOTE: ${GIT_URL} + COMMIT_INFO_SHA: ${GIT_COMMIT} + + # Cypress environment variables for run environment and CI configuration. + CYPRESS_BASE_URL: ${CYPRESS_BASE_URL} + CYPRESS_PULL_REQUEST_ID: ${CHANGE_ID} + CYPRESS_PULL_REQUEST_URL: ${CHANGE_URL} + CYPRESS_RECORD: ${CYPRESS_RECORD} + CYPRESS_RECORD_KEY: ${CYPRESS_RECORD_KEY} + + # Cloud Manager-specific test configuration. + CY_TEST_SUITE: ${CY_TEST_SUITE} + CY_TEST_REGION: ${CY_TEST_REGION} + CY_TEST_FEATURE_FLAGS: ${CY_TEST_FEATURE_FLAGS} + CY_TEST_TAGS: ${CY_TEST_TAGS} + CY_TEST_DISABLE_RETRIES: ${CY_TEST_DISABLE_RETRIES} + CY_TEST_RESET_PREFERENCES: ${CY_TEST_RESET_PREFERENCES} + CY_TEST_RESOURCE_PREFIX: ${CY_TEST_RESOURCE_PREFIX} + + # Cypress environment variables for alternative parallelization. + CY_TEST_SPLIT_RUN: ${CY_TEST_SPLIT_RUN} + CY_TEST_SPLIT_RUN_TOTAL: ${CY_TEST_SPLIT_RUN_TOTAL} + CY_TEST_SPLIT_RUN_INDEX: ${CY_TEST_SPLIT_RUN_INDEX} + CY_TEST_SPLIT_RUN_WEIGHTS: ${CY_TEST_SPLIT_RUN_WEIGHTS} + + # Cypress performance. + CY_TEST_ACCOUNT_CACHE_DIR: ${CY_TEST_ACCOUNT_CACHE_DIR} + + # Cypress reporting. + CY_TEST_JUNIT_REPORT: ${CY_TEST_JUNIT_REPORT} + CY_TEST_HTML_REPORT: ${CY_TEST_HTML_REPORT} + CY_TEST_USER_REPORT: ${CY_TEST_USER_REPORT} + CY_TEST_GENWEIGHTS: ${CY_TEST_GENWEIGHTS} + + # Cloud Manager build environment. + HOME: /home/node + REACT_APP_API_ROOT: ${REACT_APP_API_ROOT} + REACT_APP_CLIENT_ID: ${REACT_APP_CLIENT_ID} + REACT_APP_DISABLE_NEW_RELIC: ${REACT_APP_DISABLE_NEW_RELIC} + REACT_APP_LAUNCH_DARKLY_ID: ${REACT_APP_LAUNCH_DARKLY_ID} + REACT_APP_LOGIN_ROOT: ${REACT_APP_LOGIN_ROOT} + + # Miscellaneous Jenkins vars. + HUDSON_HOME: ${HUDSON_HOME} + HUDSON_URL: ${HUDSON_URL} + +# Volumes that will be exposed to every end-to-end Cypress runner. +x-e2e-volumes: + &default-volumes + - ./.git:/home/node/app/.git + - ./cache:/home/node/app/cache + - ./packages:/home/node/app/packages + - ./package.json:/home/node/app/package.json + - ./node_modules:/home/node/app/node_modules + +# Base Docker Compose service config for each Cypress runner. +# This can be extended/overridden on a per-runner basis for e.g.container name +# and OAuth token. +x-e2e-runners: + &default-runner + build: + context: . + dockerfile: ./packages/manager/Dockerfile + target: e2e + env_file: ./packages/manager/.env + volumes: *default-volumes + entrypoint: 'pnpm' + +services: + # Serves a local instance of Cloud Manager for Cypress to use for its tests. + # Not all of the runner containers require a local instance of Cypress, but + # this service can be used in all cases. + web: + build: + context: . + dockerfile: ./packages/manager/Dockerfile + target: manager + ports: + - "3000" + volumes: + - ./packages/manager:/home/node/app/packages/manager + - ./package.json:/home/node/app/package.json + - ./node_modules:/home/node/app/node_modules + healthcheck: + test: ['CMD', 'curl', '-f', 'http://localhost:3000'] + interval: 15s + timeout: 10s + retries: 10 + + # Cypress test runner service to run tests against a remotely-served Cloud instance. + # + # This is useful when testing against a standard Cloud Manager environment, + # like Production at cloud.linode.com, but can also be used to run tests against + # pre-Prod environments, PR preview links, and more. + cypress_remote: + <<: *default-runner + environment: + <<: *default-env + MANAGER_OAUTH: ${MANAGER_OAUTH} + + # Cypress test runner service to run tests against a local Cloud instance. + # + # This is useful when testing against a Cloud Manager instance served locally at + # `localhost:3000`, e.g. during development. + # + # If the local Cloud Manager instance is not served at `localhost:3000` (when + # served from a container, for example), prefer the `cypress_containerized` + # service instead. + cypress_local: + <<: *default-runner + environment: + <<: *default-env + MANAGER_OAUTH: ${MANAGER_OAUTH} + depends_on: + web: + condition: service_healthy + + # Cypress test runner service to run tests against a containerized Cloud instance. + # + # This service reverse proxies the given $CYPRESS_BASE_URL to `localhost:3000`. + # This is necessary for certain tests which require a secure context, which + # can typically only be achieved when Cloud is served at `localhost` or + # remotely behind SSL. + # + # For more information, refer to: + # https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts + # + # If the local Cloud Manager instance is served at `localhost:3000` (when + # running Cloud Manager locally during development, for example), prefer the + # `cypress_local` service instead. + cypress_containerized: + <<: *default-runner + build: + context: . + dockerfile: ./packages/manager/Dockerfile + target: e2e-reverse-proxy + environment: + <<: *default-env + MANAGER_OAUTH: ${MANAGER_OAUTH} + CYPRESS_BASE_URL: "http://localhost:3000" + REVERSE_PROXY_URL: ${CYPRESS_BASE_URL} + depends_on: + web: + condition: service_healthy + entrypoint: + - "/bin/sh" + - "-c" + - "caddy reverse-proxy --from $${CYPRESS_BASE_URL} --to $${REVERSE_PROXY_URL} > /dev/null 2>&1 & pnpm $0 $@" + + # Cypress component test runner service. + # + # Unlike other Cloud Manager Cypress tests, these tests can be run without + # requiring a Cloud Manager environment. + cypress_component: + <<: *default-runner + environment: + CY_TEST_DISABLE_RETRIES: ${CY_TEST_DISABLE_RETRIES} + CY_TEST_JUNIT_REPORT: ${CY_TEST_JUNIT_REPORT} + + + # --> ! DEPRECATION NOTICE ! <-- + # The services below this line are deprecated, and will be deleted soon. + # Don't build any pipelines or write any scripts that depend on these. + # Instead, opt to use `cypress_local` in places where you would've used `e2e`, + # use `cypress_remote` in places where you would've used `e2e_heimdall`, and + # use `cypress_component` in places where you would've used `component`. + + # Generic end-to-end test runner for Cloud's primary testing pipeline. + # Configured to run against a local Cloud instance. + e2e: + <<: *default-runner + environment: + <<: *default-env + MANAGER_OAUTH: ${MANAGER_OAUTH} + entrypoint: ['pnpm', 'cy:e2e'] + + # Component test runner. + # Does not require any Cloud Manager environment to run. + component: + <<: *default-runner + depends_on: [] + environment: + CY_TEST_DISABLE_RETRIES: ${CY_TEST_DISABLE_RETRIES} + CY_TEST_JUNIT_REPORT: ${CY_TEST_JUNIT_REPORT} + entrypoint: ['pnpm', 'cy:component:run'] + + # End-to-end test runner for Cloud's synthetic monitoring tests. + # Configured to run against a remote Cloud instance hosted at some URL. + e2e_heimdall: + <<: *default-runner + depends_on: [] + environment: + <<: *default-env + MANAGER_OAUTH: ${MANAGER_OAUTH} + entrypoint: ['pnpm', 'cy:e2e'] diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts new file mode 100644 index 00000000000..a52cfee08aa --- /dev/null +++ b/docs/.vitepress/config.ts @@ -0,0 +1,26 @@ +import { generateSidebar } from "./plugins/sidebar"; + +export const DOCS_SRC_DIR = new URL("./../", import.meta.url).pathname; + +export default { + title: "Cloud Manager Docs", + description: "Akamai Cloud Manger Documentation", + srcDir: DOCS_SRC_DIR, + base: "/manager/", + themeConfig: { + logo: "/akamai-wave.svg", + nav: [ + { text: "Home", link: "/" }, + { text: "Getting Started", link: "/GETTING_STARTED" }, + { text: "Contributing", link: "/CONTRIBUTING" }, + ], + search: { + provider: "local", + }, + sidebar: generateSidebar(DOCS_SRC_DIR), + socialLinks: [ + { icon: "github", link: "https://github.com/linode/manager" }, + ], + }, + head: [["link", { rel: "icon", href: "/manager/favicon.ico" }]], +}; diff --git a/docs/.vitepress/plugins/sidebar.ts b/docs/.vitepress/plugins/sidebar.ts new file mode 100644 index 00000000000..228af1d39da --- /dev/null +++ b/docs/.vitepress/plugins/sidebar.ts @@ -0,0 +1,89 @@ +import { readdirSync } from "fs"; +import { join } from "path"; +import { DOCS_SRC_DIR } from "../config"; + +type LinkItem = { text: string; link: string }; + +type SidebarItem = + | { + text: string; + collapsed?: boolean; + items: SidebarItem[] | LinkItem[]; + } + | LinkItem; + +const exclude = [ + "cache", + "public", + "PULL_REQUEST_TEMPLATE.md", + ".vitepress", + "index.md", +]; + +const replacements = [ + ["-", " "], + ["_", " "], + [".md", ""], +]; + +function isPathIgnored(path: string) { + for (const item of exclude) { + if (path.includes(item)) { + return true; + } + } + return false; +} + +function capitalize(s: string) { + return ( + s.substring(0, 1).toUpperCase() + s.substring(1, s.length).toLowerCase() + ); +} + +/** + * Given a file name, this function returns a formatted title. + */ +function formatSidebarItemText(fileName: string) { + // removes -, _, and .md from files names to generate the title + for (const [from, to] of replacements) { + fileName = fileName.replaceAll(from, to); + } + // Removes any number prefix. This allows us to order things by putting numbers in file names. + fileName = fileName.replace(/^[0-9]*/, ""); + // Capitalizes each word in the file name + fileName = fileName.split(" ").map(capitalize).join(" "); + return fileName; +} + +/** + * Generates a VitePress sidebar by recursively traversing the given directory. + */ +export function generateSidebar(dir: string) { + const files = readdirSync(dir, { withFileTypes: true }); + + const sidebar: SidebarItem[] = []; + + for (const file of files) { + const filepath = join(dir, file.name); + + if (isPathIgnored(filepath)) { + continue; + } + + if (file.isDirectory()) { + sidebar.push({ + text: formatSidebarItemText(file.name), + collapsed: false, + items: generateSidebar(filepath), + }); + } else { + sidebar.push({ + text: formatSidebarItemText(file.name), + link: filepath.split(DOCS_SRC_DIR)[1], + }); + } + } + + return sidebar; +} diff --git a/docs/.vitepress/tsconfig.json b/docs/.vitepress/tsconfig.json new file mode 100644 index 00000000000..163fc24b10e --- /dev/null +++ b/docs/.vitepress/tsconfig.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "lib": ["ESNext"], + "module": "ESNext", + } +} diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md new file mode 100644 index 00000000000..a435d4ca663 --- /dev/null +++ b/docs/CONTRIBUTING.md @@ -0,0 +1,79 @@ +# Contributing + +Thanks for your interest in contributing to the Linode Cloud Manager! + +You can contribute by [opening an issue](https://github.com/linode/manager/issues/new) or submitting a pull request. + +## Opening an issue + +Feel free to open an issue to report a bug or request a feature. + +## Submitting a pull request + +1. Fork this repository. +2. Clone your fork to your local machine. +3. Create a branch from `develop`, e.g. `$ git checkout develop && git pull && git checkout -b feature/my-feature`. +4. Make your [small, focused](#sizing-a-pull-request) changes, commit them following the standards below, and then push them to your fork. +5. Commit message format standard: `: [JIRA-ticket-number] - ` + + **Commit Types:** + - `feat`: New feature for the user (not a part of the code, or ci, ...). + - `fix`: Bugfix for the user (not a fix to build something, ...). + - `change`: Modifying an existing visual UI instance. Such as a component or a feature. + - `refactor`: Restructuring existing code without changing its external behavior or visual UI. Typically to improve readability, maintainability, and performance. + - `test`: New tests or changes to existing tests. Does not change the production code. + - `upcoming`: A new feature that is in progress, not visible to users yet, and usually behind a feature flag. + + **Example:** `feat: [M3-1234] - Allow user to view their login history` + +6. Open a pull request against `develop` and make sure the title follows the same format as the commit message. +7. Keep in mind that our repository is public and open source! Before adding screenshots to your PR, we recommend you enable the **Mask Sensitive Data** setting in Cloud Manager [Profile Settings](https://cloud.linode.com/profile/settings). +8. If needed, create a changeset to populate our changelog. + - If you don't have the Github CLI installed or need to update it (you need GH CLI 2.21.0 or greater), + - install it via `brew`: https://github.com/cli/cli#installation or upgrade with `brew upgrade gh` + - Once installed, run `gh repo set-default` and pick `linode/manager` (only > 2.21.0) + - You can also just create the changeset manually, in this case make sure to use the proper formatting for it. + - Run `pnpm changeset`from the root, choose the package to create a changeset for, and provide a description for the change. + You can either have it committed automatically or do it manually if you need to edit it. + - A changeset is optional, but should be included if the PR falls in one of the following categories:
+ `Added`, `Fixed`, `Changed`, `Removed`, `Tech Stories`, `Tests`, `Upcoming Features` + - Select the changeset category that matches the commit type in your PR title. (Where this isn't a 1:1 match: generally, a `feat` commit type falls under an `Added` change and `refactor` falls under `Tech Stories`.) + - Write your changeset by following our [best practices](#writing-a-changeset). +9. Automated tests and other CI checks will run automatically against the PR. It is the contributor's responsibility to ensure their changes pass the CI checks. + +Two reviews from members of the Cloud Manager team are required before merge. After approval, all pull requests are squash merged. + +## Writing a changeset + +Follow these best practices to write a good changeset: + +- Summarize your changes succinctly in 150 characters or less. A changeset shouldn't describe every line of code edited in the PR. +- Use a consistent tense in all changeset entries. We have chosen to use **imperative (present)** tense. (This follows established [git commit message best practices](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).) +- Avoid starting a changeset with the verb "Add", "Remove", "Change" or "Fix" when listed under that respective `Added`, `Removed`, `Changed` or `Fixed` section. It is unnecessary repetition. +- For `Fixed` changesets, describe the bug that needed to be fixed, rather than the fix itself. (e.g. say "Missing button labels in action buttons" rather than "Make label prop required for action buttons"). +- Begin a changeset with a capital letter, but do not end it with a period; it's not a complete sentence. +- When referencing code, consider adding backticks for readability. (e.g. "Update `updateImageRegions` to accept `UpdateImageRegionsPayload` instead of `regions: string[]`"). +- Use the `Upcoming Features` section for ongoing project work that is behind a feature flag. If additional changes are being made that are not feature flagged, add another changeset to describe that work. +- Add changesets for `docs/` documentation changes in the `manager` package, as this is generally best-fit. +- Generally, if the code change is a fix for a previous change that has been merged to `develop` but was never released to production, we don't need to include a changeset. + +## Sizing a pull request + +A good PR is small. + +Examples of ‘small’: + +- Changing a docker file +- Updating a dependency ([Example 1](https://github.com/linode/manager/pull/10291), [Example 2](https://github.com/linode/manager/pull/10212)) +- Fixing 1 bug ([Example 1](https://github.com/linode/manager/pull/10583), [Example 2](https://github.com/linode/manager/pull/9726)) +- Creating 1 new component with unit test coverage ([Example](https://github.com/linode/manager/pull/9520)) +- Adding a new util with unit test coverage + +Diff size: A good PR is less than 500 changes, closer to [200](https://github.com/google/eng-practices/blob/master/review/developer/small-cls.md). + +A good PR does **exactly one thing**, and is clear about what that is in the description. +Break down *additional* things in your PR into multiple PRs (like you would do with tickets). + +## Docs + +To run the docs development server locally, [install Bun](https://bun.sh/) and start the server: `pnpm run docs`. diff --git a/docs/GETTING_STARTED.md b/docs/GETTING_STARTED.md new file mode 100644 index 00000000000..b4b99f6102a --- /dev/null +++ b/docs/GETTING_STARTED.md @@ -0,0 +1,61 @@ +# Getting Started + +1. Fork this repository. +2. Clone your fork to your local machine. +3. Go to [cloud.linode.com/profile/clients](https://cloud.linode.com/profile/clients) and click "Add an OAuth App". +4. Enter a label, set the callback URL to `http://localhost:3000/oauth/callback`, and check the "Public" checkbox. +5. After your OAuth App has been created, copy the ID (not the secret). +6. In `packages/manager`, copy the contents of `.env.example` and paste them into a new file called `.env`. +7. In `.env` set `REACT_APP_CLIENT_ID` to the ID from step 5. +8. Install Node.js 22.19 LTS. We recommend using [Volta](https://volta.sh/): + + ```bash + curl https://get.volta.sh | bash + + ## Add volta to your .*rc file, or open a new terminal window. + + volta install node@22.19 + + node --version + ## v22.19.0 + ``` + +9. Install pnpm v10 using Volta or view the [pnpm docs](https://pnpm.io/installation) for more installation methods + + ```bash + volta install pnpm@10 + + pnpm --version + # 10.2.0 + ``` + +10. Navigate to the root directory of the repository +11. Run `pnpm bootstrap` to install dependencies and perform an initial build of our packages +12. Run `pnpm dev` to start the local development server. Cloud Manager should be running at `http://localhost:3000` + +## Serving a production build of Cloud Manager + +You can build a production bundle of Cloud Manager and serve it locally. + +```bash +pnpm install + +pnpm run --filter @linode/validation build # build the @linode/validation package + +pnpm run --filter @linode/api-v4 build # build the @linode/api-v4 (it depends on @linode/validation) + +pnpm run --filter linode-manager build # build a production bundle of Cloud Manager + +pnpm run --filter linode-manager start:ci # start a local http server on http://localhost:3000/ +``` + +## Exposing Cloud Manager's dev server to the network + +By default, Cloud Manager's dev server only listens on `localhost`. If you need to +expose the Vite dev server to all network interfaces, you can use the following command. + +> **Note**: This is useful for running Cloud Manager's dev server in Docker-like environments + +```bash +pnpm run up:expose +``` diff --git a/docs/PULL_REQUEST_TEMPLATE.md b/docs/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000000..b853c2b97eb --- /dev/null +++ b/docs/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,109 @@ +## Description 📝 + +Highlight the Pull Request's context and intentions. + +## Changes 🔄 + +List any change(s) relevant to the reviewer. + +- ... +- ... + +### Scope 🚢 + + Upon production release, changes in this PR will be visible to: + +- [ ] All customers +- [ ] Some customers (e.g. in Beta or Limited Availability) +- [ ] No customers / Not applicable + +## Target release date 🗓️ + +Please specify a release date (and environment, if applicable) to guarantee timely review of this PR. If exact date is not known, please approximate and update it as needed. + +## Preview 📷 + +**Include a screenshot `` or video `