Skip to content

gsa-clone/EDX-github-action

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 

Repository files navigation

GSA EDX GitHub Action

GitHub Action to run GSA EDX Lighthouse plugin

This composite action integrates Lighthouse CI and the lighthouse-plugin-edx with Github Actions. The results of the Lighthouse audit are added as a pull request comment.

Screen shot of pull request comment

Example

Run Lighthouse on each pull request.

Create .github/workflows/main.yml and include the EDX-github-action step.

name: Lighthouse CI

on: [pull_request]

permissions:
  pull-requests: write

jobs:
  lighthouse:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 16
          cache: "npm"
      - run: npm ci
      - name: Audit site using Lighthouse
        uses: GSA/EDX-github-action@v1

Make a lighthouserc.json file with LHCI assertion syntax.

lighthouserc.json

{
  "ci": {
    "collect": {
      "settings": {
        "plugins": ["lighthouse-plugin-edx"]
      },
      "startServerCommand": "NODE_ENV=production npm run start",
      "url": ["http://localhost:3000"]
    }
  }
}

Recipes

Use a directory of static files instead of a URL

Create .github/workflows/main.yml and include the EDX-github-action step.

main.yml

name: Lighthouse CI

on: [pull_request]

permissions:
  pull-requests: write

jobs:
  lighthouse:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 16
          cache: "npm"
      - run: npm ci
      - run: npm run build
      - name: Audit site using Lighthouse
        uses: GSA/EDX-github-action@v1

Make a lighthouserc.json file with LHCI assertion syntax.

lighthouserc.json

{
  "ci": {
    "collect": {
      "settings": {
        "plugins": ["lighthouse-plugin-edx"]
      },
      "staticDistDir": "./_site"
    }
  }
}
Integrate with a Jekyll based site

Create .github/workflows/main.yml and include the EDX-github-action step.

main.yml

name: Lighthouse CI

on: [pull_request]

permissions:
  pull-requests: write

jobs:
  lighthouse:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: "2.7"
          bundler-cache: true
      - name: Audit site using Lighthouse
        uses: GSA/EDX-github-action@v1

Make a lighthouserc.json file with LHCI assertion syntax.

lighthouserc.json

{
  "ci": {
    "collect": {
      "settings": {
        "plugins": ["lighthouse-plugin-edx"]
      },
      "startServerCommand": "bundle exec jekyll serve",
      "url": ["http://localhost:4000"]
    }
  }
}
Use a configuration file in a custom location

Create .github/workflows/main.yml and include the EDX-github-action step.

main.yml

name: Lighthouse CI

on: [pull_request]

permissions:
  pull-requests: write

jobs:
  lighthouse:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Audit site using Lighthouse
        uses: GSA/EDX-github-action@v1
        with:
          config-path: "./some/dir/lighthouserc.json"

Make a lighthouserc.json file with LHCI assertion syntax.

lighthouserc.json

{
  "ci": {
    "collect": {
      "settings": {
        "plugins": ["lighthouse-plugin-edx"]
      },
      "url": ["http://localhost:4000"]
    }
  }
}

Inputs

config-path

Optional Path to Lighthouse configuration file.

Outputs

See https://github.com/treosh/lighthouse-ci-action/blob/main/README.md#outputs

About

GitHub Action to run GSA EDX Lighthouse plugin

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors