diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000000..aedff628d6f1 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,49 @@ +version: 2 +updates: + # Maintain dependencies for npm/yarn packages + - package-ecosystem: "npm" + directory: "/" + schedule: + interval: "weekly" + day: "monday" + time: "09:00" + timezone: "UTC" + open-pull-requests-limit: 10 + labels: + - "dependencies" + - "automated" + commit-message: + prefix: "chore(deps)" + groups: + # Group minor and patch updates together + minor-and-patch: + patterns: + - "*" + update-types: + - "minor" + - "patch" + ignore: + # Ignore major version updates for stability - these should be reviewed manually + - dependency-name: "*" + update-types: ["version-update:semver-major"] + + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + day: "monday" + time: "09:00" + timezone: "UTC" + open-pull-requests-limit: 5 + labels: + - "dependencies" + - "github-actions" + - "automated" + commit-message: + prefix: "chore(ci)" + groups: + # Group all GitHub Actions updates together + actions: + patterns: + - "*" diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 000000000000..d44d05c83cf3 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,49 @@ +name: "CodeQL Security Analysis" + +on: + push: + branches: + - main + pull_request: + branches: + - main + schedule: + # Run weekly on Sundays at 00:00 UTC + - cron: "0 0 * * 0" + workflow_dispatch: + +permissions: + actions: read + contents: read + security-events: write + +jobs: + analyze: + name: Analyze + runs-on: blacksmith-4vcpu-ubuntu-2404 + timeout-minutes: 30 + + strategy: + fail-fast: false + matrix: + language: + - javascript-typescript + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + # Use default queries plus security-extended and security-and-quality + queries: security-extended,security-and-quality + + - name: Autobuild + uses: github/codeql-action/autobuild@v3 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{ matrix.language }}" diff --git a/.github/workflows/deploy-staging.yml b/.github/workflows/deploy-staging.yml new file mode 100644 index 000000000000..7df7a51cf44a --- /dev/null +++ b/.github/workflows/deploy-staging.yml @@ -0,0 +1,94 @@ +name: Deploy to Staging + +on: + push: + branches: + - main + workflow_dispatch: + inputs: + environment: + description: "Environment to deploy to" + required: true + default: "staging" + type: choice + options: + - staging + +permissions: + contents: read + packages: write + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push: + name: Build and Push Docker Image + runs-on: blacksmith-4vcpu-ubuntu-2404 + outputs: + image-tag: ${{ steps.meta.outputs.tags }} + image-digest: ${{ steps.build.outputs.digest }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=sha,prefix=staging- + type=raw,value=staging-latest + + - name: Build and push Docker image + id: build + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + build-args: | + NEXT_PUBLIC_WEBAPP_URL=${{ vars.STAGING_WEBAPP_URL }} + NEXT_PUBLIC_API_V2_URL=${{ vars.STAGING_API_V2_URL }} + + deploy: + name: Deploy to Staging + needs: build-and-push + runs-on: blacksmith-2vcpu-ubuntu-2404 + environment: + name: staging + url: ${{ vars.STAGING_WEBAPP_URL }} + steps: + - name: Deploy notification + run: | + echo "Deploying image with digest: ${{ needs.build-and-push.outputs.image-digest }}" + echo "Image tags: ${{ needs.build-and-push.outputs.image-tag }}" + echo "" + echo "To complete the deployment, configure your staging environment to pull the new image." + echo "Image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:staging-latest" + + - name: Create deployment summary + run: | + echo "## Staging Deployment Summary" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY + echo "**Image:** \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:staging-latest\`" >> $GITHUB_STEP_SUMMARY + echo "**Digest:** \`${{ needs.build-and-push.outputs.image-digest }}\`" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "The Docker image has been built and pushed to the container registry." >> $GITHUB_STEP_SUMMARY + echo "Configure your staging infrastructure to pull this image for deployment." >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 83605ea5ccba..f43d2d535dff 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -85,10 +85,12 @@ jobs: - uses: ./.github/actions/cache-db - name: Run Tests run: VITEST_MODE=integration yarn test - # TODO: Generate test results so we can upload them - # - name: Upload Test Results - # if: ${{ always() }} - # uses: actions/upload-artifact@v4 - # with: - # name: test-results - # path: test-results + - name: Upload Test Results + if: always() + uses: actions/upload-artifact@v4 + with: + name: integration-test-results + path: | + coverage/ + test-results/ + retention-days: 14 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 76dd0d24a400..9e7953f8cb53 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,4 +14,3 @@ jobs: - uses: ./.github/actions/yarn-install - name: Run Lint run: yarn lint - continue-on-error: true diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index a922ec9698aa..81c106bdbeb4 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -15,6 +15,14 @@ jobs: - uses: ./.github/actions/dangerous-git-checkout - uses: ./.github/actions/yarn-install - run: yarn prisma generate - - run: yarn test -- --no-isolate - # We could add different timezones here that we need to run our tests in - - run: TZ=America/Los_Angeles VITEST_MODE=timezone yarn test -- --no-isolate + - name: Run unit tests with coverage + run: yarn test -- --no-isolate --coverage + - name: Run timezone-dependent tests + run: TZ=America/Los_Angeles VITEST_MODE=timezone yarn test -- --no-isolate + - name: Upload coverage reports + if: always() + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: coverage/ + retention-days: 14