diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..a2187600b --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,171 @@ +version: 2.1 +orbs: + utils: ethereum-optimism/circleci-utils@0.0.7 + +executors: + node20: + docker: + - image: cimg/node:20.11.1 # Prebuilt CircleCI image for Node.js 20.x + resource_class: medium # Adjust resource allocation as needed + ubuntu: + machine: + image: ubuntu-2204:current + rust: + docker: + - image: cimg/rust:1.75.0 # CircleCI's Rust Docker image + working_directory: ~/project + +commands: + setup-node: + steps: + - run: + name: Install Node.js (20.x) and pnpm + command: | + curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - + sudo apt-get install -y nodejs + npm install -g pnpm + pnpm --version + - restore_cache: + keys: + - v1-pnpm-cache-{{ checksum "pnpm-lock.yaml" }} + - run: + name: Install dependencies + command: npm install -g pnpm && pnpm install + - save_cache: + key: v1-pnpm-cache-{{ checksum "pnpm-lock.yaml" }} + paths: + - ~/.pnpm-store + +jobs: + algolia: + description: Create and upload Algolia search index + executor: ubuntu + steps: + - checkout + - setup-node + - run: + name: Create and upload index + command: | + # index:docs requires the following environment variables, coming from the algolia-search context + # ALGOLIA_APPLICATION_ID + # ALGOLIA_WRITE_API_KEY + # ALGOLIA_INDEX_NAME + pnpm run index:docs + + breadcrumbs: + description: Check breadcrumbs in documentation + executor: ubuntu + steps: + - checkout + - setup-node + - run: + name: Run breadcrumb check + command: pnpm check-breadcrumbs + lint: + description: Lint Markdown files + executor: ubuntu + steps: + - checkout + - setup-node + - run: + name: Lint Markdown files + command: pnpm lint + + links: + executor: rust + steps: + - checkout: + path: docs + - run: + name: Checkout lycheeverse/lychee + command: | + git clone https://github.com/lycheeverse/lychee.git lychee + + - restore_cache: + keys: + - v1-rust-cache-{{ checksum "lychee/Cargo.lock" }} + - v1-rust-cache- + + - run: + name: Build Lychee + command: | + cd lychee + cargo build --release + + - save_cache: + key: v1-rust-cache-{{ checksum "lychee/Cargo.lock" }} + paths: + - ~/.cargo/registry + - ~/.cargo/git + - lychee/target + + - run: + name: Run Lychee link checker + command: | + export PATH=$PATH:$HOME/project/lychee/target/release + cd docs + lychee --config ./lychee.toml --quiet "./pages" + + developer-metrics: + description: Monthly Metrics Report + executor: ubuntu + parameters: + repo: + type: string + default: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME + steps: + - utils/get-github-access-token: + private-key-str: GITHUB_APP_KEY + app-id: GITHUB_APP_ID + repo: << parameters.repo >> + - run: + name: Get Dates for Last Month + command: | + # Calculate the first day of the previous month + first_day=$(date -d "last month" +%Y-%m-01) + + + # Calculate the last day of the previous month + last_day=$(date -d "$first_day +1 month -1 day" +%Y-%m-%d) + + # Export the last_month variable for subsequent steps + echo "export LAST_MONTH=${first_day}..${last_day}" >> $BASH_ENV + - utils/generate-issue-metrics-file: + SEARCH_QUERY: 'repo:ethereum-optimism/docs is:issue closed:${LAST_MONTH} -reason:\"not planned\" -label:monthly-report' + file-path: "./closed_issue_metrics.md" + - utils/create-github-issue-from-file: + repo: << parameters.repo >> + file-path: "./closed_issue_metrics.md" + issue-title: "${LAST_MONTH} metrics report for closed issues" + issue-labels: "monthly-report" + assignees: "sbvegan" + - utils/generate-issue-metrics-file: + SEARCH_QUERY: "repo:ethereum-optimism/docs is:pr created:${LAST_MONTH}" + file-path: "./pr_issue_metrics.md" + - utils/create-github-issue-from-file: + repo: << parameters.repo >> + file-path: "./pr_issue_metrics.md" + issue-title: "${LAST_MONTH} metrics report for opened prs" + issue-labels: "monthly-report" + assignees: "sbvegan" + +workflows: + merge-workflow: + jobs: + - algolia: + name: Algolia Index Update + context: algolia-search + filters: + branches: + only: main + pr-workflow: + jobs: + - breadcrumbs + - links + - lint + monthly-workflow: + when: + equal: [build_monthly, <>] + jobs: + - developer-metrics: + context: circleci-repo-docs diff --git a/.github/workflows/algolia.yml b/.github/workflows/algolia.yml deleted file mode 100644 index 252b78306..000000000 --- a/.github/workflows/algolia.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Algolia Index Update - -on: - push: - branches: [main] - -jobs: - lint: - runs-on: ubuntu-latest - - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: "20.x" - - - name: Install pnpm - run: npm install -g pnpm - - - name: Install dependencies - run: pnpm install - - - name: Create and upload index - env: - ALGOLIA_APPLICATION_ID: ${{ secrets.ALGOLIA_APPLICATION_ID }} - ALGOLIA_WRITE_API_KEY: ${{ secrets.ALGOLIA_WRITE_API_KEY }} - ALGOLIA_INDEX_NAME: ${{ secrets.ALGOLIA_INDEX_NAME }} - run: pnpm index:docs diff --git a/.github/workflows/breadcrumbs.yml b/.github/workflows/breadcrumbs.yml deleted file mode 100644 index a077cf137..000000000 --- a/.github/workflows/breadcrumbs.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Check Breadcrumbs - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - paths: - - 'pages/**/*.mdx' - - 'pages/**/*.md' - -jobs: - check-breadcrumbs: - runs-on: ubuntu-latest - - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: '20.x' - - - name: Install pnpm - run: npm install -g pnpm - - - name: Install dependencies - run: pnpm install - - - name: Run breadcrumb check - run: pnpm check-breadcrumbs \ No newline at end of file diff --git a/.github/workflows/links.yml b/.github/workflows/links.yml deleted file mode 100644 index 4461adada..000000000 --- a/.github/workflows/links.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Check Links - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - build-and-run-lychee: - runs-on: ubuntu-latest - - steps: - - name: Checkout ethereum-optimism/docs - uses: actions/checkout@v2 - with: - repository: 'ethereum-optimism/docs' - path: 'docs' - - - name: Checkout lycheeverse/lychee - uses: actions/checkout@v2 - with: - repository: 'lycheeverse/lychee' - path: 'lychee' - - - name: Set up Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - - - name: Cache Rust dependencies - uses: Swatinem/rust-cache@v2 - with: - save-if: ${{ github.ref == 'refs/heads/main' }} - - - name: Build Lychee - run: | - cd lychee - cargo build --release - - - name: Add Lychee to PATH - run: echo "$GITHUB_WORKSPACE/lychee/target/release" >> $GITHUB_PATH - - - name: Run Lychee - run: | - cd docs - lychee --config ./lychee.toml --quiet "./pages" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index f25f60081..000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Lint Markdown - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - lint: - runs-on: ubuntu-latest - - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: '20.x' - - - name: Install pnpm - run: npm install -g pnpm - - - name: Install dependencies - run: pnpm install - - - name: Run lint - run: pnpm lint diff --git a/.github/workflows/monthly-issue-metircs.yml b/.github/workflows/monthly-issue-metircs.yml deleted file mode 100644 index 97b6ed183..000000000 --- a/.github/workflows/monthly-issue-metircs.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: Monthly Issue Metrics Report -on: - workflow_dispatch: - schedule: - - cron: '0 0 1 * *' - -permissions: - issues: write - pull-requests: read - -jobs: - build: - name: docs issue metrics - runs-on: ubuntu-latest - - steps: - - - name: Get dates for last month - shell: bash - run: | - # Calculate the first day of the previous month - first_day=$(date -d "last month" +%Y-%m-01) - - # Calculate the last day of the previous month - last_day=$(date -d "$first_day +1 month -1 day" +%Y-%m-%d) - - #Set an environment variable with the date range - echo "$first_day..$last_day" - echo "last_month=$first_day..$last_day" >> "$GITHUB_ENV" - - - name: Run issue-metrics tool for issues last month - uses: github/issue-metrics@v2 - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SEARCH_QUERY: 'repo:ethereum-optimism/docs is:issue created:${{ env.last_month }} -reason:"not planned" -label:monthly-report' - - - name: Create issue for opened issues - uses: peter-evans/create-issue-from-file@v4 - with: - title: ${{ env.last_month }} metrics report for opened issues - token: ${{ secrets.GITHUB_TOKEN }} - content-filepath: ./issue_metrics.md - assignees: sbvegan - labels: | - monthly-report - - - name: Run issue-metrics tool for issues last month - uses: github/issue-metrics@v2 - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SEARCH_QUERY: 'repo:ethereum-optimism/docs is:issue closed:${{ env.last_month }} -reason:"not planned" -label:monthly-report' - - - name: Create issue for closed issues - uses: peter-evans/create-issue-from-file@v4 - with: - title: ${{ env.last_month }} metrics report for closed issues - content-filepath: ./issue_metrics.md - assignees: sbvegan - labels: | - monthly-report diff --git a/.github/workflows/monthly-pr-metrics.yml b/.github/workflows/monthly-pr-metrics.yml deleted file mode 100644 index efeb11c95..000000000 --- a/.github/workflows/monthly-pr-metrics.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: Monthly PR Metrics Report -on: - workflow_dispatch: - schedule: - - cron: '0 0 1 * *' - -permissions: - issues: write - pull-requests: read - -jobs: - build: - name: developer pr metrics - runs-on: ubuntu-latest - - steps: - - - name: Get dates for last month - shell: bash - run: | - # Calculate the first day of the previous month - first_day=$(date -d "last month" +%Y-%m-01) - - # Calculate the last day of the previous month - last_day=$(date -d "$first_day +1 month -1 day" +%Y-%m-%d) - - #Set an environment variable with the date range - echo "$first_day..$last_day" - echo "last_month=$first_day..$last_day" >> "$GITHUB_ENV" - - - name: Run issue-metrics tool for prs last month - uses: github/issue-metrics@v2 - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SEARCH_QUERY: 'repo:ethereum-optimism/docs is:pr created:${{ env.last_month }}' - - - name: Create issue for opened prs - uses: peter-evans/create-issue-from-file@v4 - with: - title: ${{ env.last_month }} metrics report for opened prs - token: ${{ secrets.GITHUB_TOKEN }} - content-filepath: ./issue_metrics.md - assignees: sbvegan - labels: | - monthly-report - - - name: Run issue-metrics tool for prs closed last month - uses: github/issue-metrics@v2 - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SEARCH_QUERY: 'repo:ethereum-optimism/docs is:pr closed:${{ env.last_month }}' - - - name: Create issue for closed prs last month - uses: peter-evans/create-issue-from-file@v4 - with: - title: ${{ env.last_month }} metrics report for closed prs - content-filepath: ./issue_metrics.md - assignees: sbvegan - labels: | - monthly-report \ No newline at end of file diff --git a/.github/workflows/tutorials.yml b/.github/workflows/tutorials.yml deleted file mode 100644 index 7018045f1..000000000 --- a/.github/workflows/tutorials.yml +++ /dev/null @@ -1,124 +0,0 @@ -name: Check Tutorials - -on: - workflow_dispatch: - schedule: - - cron: '0 0 * * *' # Runs at 00:00 UTC every day - -concurrency: - group: shared-tutorial-key - cancel-in-progress: false - -jobs: - cross-dom-bridge-eth: - runs-on: ubuntu-latest - - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: '20.x' - - - name: Install pnpm - run: npm install -g pnpm - - - name: Install dependencies - run: pnpm install - - - name: Run tutorial - env: - TUTORIAL_PRIVATE_KEY: ${{ secrets.TUTORIAL_PRIVATE_KEY }} - run: - node ./public/tutorials/cross-dom-bridge-eth.js - - - name: Notify Slack on failure - uses: ravsamhq/notify-slack-action@v2 - if: always() - with: - status: ${{ job.status }} - notify_when: "failure" - notification_title: "{workflow} has {status_message} (<{run_url}|view errors>)" - message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>" - footer: "<{run_url}|View Run>" - mention_users_when: "failure,warnings" - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - - send-tx-from-eth: - needs: cross-dom-bridge-eth - runs-on: ubuntu-latest - - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: '20.x' - - - name: Install pnpm - run: npm install -g pnpm - - - name: Install dependencies - run: pnpm install - - - name: Run tutorial - env: - TUTORIAL_PRIVATE_KEY: ${{ secrets.TUTORIAL_PRIVATE_KEY }} - run: - node ./public/tutorials/send-tx-from-eth.js - - - name: Notify Slack on failure - uses: ravsamhq/notify-slack-action@v2 - if: always() - with: - status: ${{ job.status }} - notify_when: "failure" - notification_title: "{workflow} has {status_message} (<{run_url}|view errors>)" - message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>" - footer: "<{run_url}|View Run>" - mention_users_when: "failure,warnings" - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - - sdk-estimate-costs: - needs: send-tx-from-eth - runs-on: ubuntu-latest - - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: '20.x' - - - name: Install pnpm - run: npm install -g pnpm - - - name: Install dependencies - run: pnpm install - - - name: Run tutorial - env: - TUTORIAL_PRIVATE_KEY: ${{ secrets.TUTORIAL_PRIVATE_KEY }} - run: - node ./public/tutorials/sdk-estimate-costs.js - - - name: Notify Slack on failure - uses: ravsamhq/notify-slack-action@v2 - if: always() - with: - status: ${{ job.status }} - notify_when: "failure" - notification_title: "{workflow} has {status_message} (<{run_url}|view errors>)" - message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>" - footer: "<{run_url}|View Run>" - mention_users_when: "failure,warnings" - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}