diff --git a/.github/workflows/build-audit.yml b/.github/workflows/build-audit.yml index eb3476d..858d2c1 100644 --- a/.github/workflows/build-audit.yml +++ b/.github/workflows/build-audit.yml @@ -1,5 +1,5 @@ --- -# yamllint disable rule:key-ordering +# yamllint disable rule:key-ordering rule:line-length name: build-audit on: # yamllint disable-line pull_request: @@ -11,16 +11,30 @@ on: # yamllint disable-line - synchronize - reopened jobs: - # yamllint disable rule:line-length - audit-only: + build-unminified-site: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 - - name: Run audit-build-action-hugo using config from tests/config + - uses: actions/checkout@v4 + - name: Build site with Hugo and audit uses: wildtechgarden/audit-build-action-hugo@main with: base-url: "https://example.com/" config-file: hugo.toml hugo-version: latest + upload-site-as: unminified-site source-directory: tests/config + - name: Validate HTML in output-directory + uses: ./ + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + use-existing-workspace: "true" + validate-html-artifact: + needs: build-unminified-site + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - name: Validate HTML from artifact + uses: ./ + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} ... diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 67c973b..432bec5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -115,7 +115,7 @@ repos: hooks: - id: editorconfig-checker alias: ec - exclude: ^(LICENSE$|README.md$|package(-lock)?.json$|_vendor) + exclude: ^(LICENSE$|README.*\.md$|package(-lock)?.json$|_vendor) - repo: "https://github.com/streetsidesoftware/cspell-cli" rev: v7.3.0 diff --git a/README.fr.md b/README.fr.md index a34f51d..eec14b5 100644 --- a/README.fr.md +++ b/README.fr.md @@ -10,18 +10,64 @@ Statut IC: [![pre-commit.ci statut](https://results.pre-commit.ci/badge/github/w ## Matières 1. [Matières](#matières) -2. [Fonctionnalités](#fonctionnalités) -3. [Utilisation](#utilisation) -4. [Développement](#développement) -5. [Colophon](#colophon) +2. [Configuration and utilisation](#configuration-and-utilisation) + 1. [Actions inputs variables](#actions-inputs-variables) + 2. [Sample usage](#sample-usage) +3. [Développement](#développement) +4. [Colophon](#colophon) -## Fonctionnalités +## Configuration and utilisation -TBD +### Actions inputs variables -## Utilisation +| Input | Required | Default | Dit-on | +|-------|-------|---------|---------| +| download-site-as | oui | unminified-site | GitHub Artifact qui contenu le tarball avec le site | +| download-site-filename | oui | hugo-site.tar | Nom de tarball qui contenu le site | +| output-directory | oui | public | subdirectory (en tarball) contenu le site a vérifier | +| repo-token | oui | _(none)_ | GITHUB_TOKEN | +| use-existing-workspace | non | false | Utiliser un workspace existent et le site créer vers un artefact | -TBD +Le tarball (défaut ``hugo-site.tar``) en l'artefact (défaut +``unminified-site``) avec le nom en ``download-site-as`` et contenu: + +* Un subdirectory contenu le site (défaut: _public_, ou option +á ``output-directory``). + +### Sample usage + +```yaml +name: test-html-validate +on: + pull_request: + types: + - assigned + - opened + - synchronize + - reopened + push: + branches: + - main +jobs: + build-unminified-site: + runs-on: ubuntu-20.04 + steps: + - name: "Créer site avec Hugo et auditer" + uses: wildtechgarden/audit-build-action-hugo-dfd@main + with: + base-url: "https://www.example.com/" + build-for-downstream: "true" + source-directory: échantillon + use-lfs: false + - uses: actions/checkout@v3 + with: + path: validate-html-action + - name: "Vérifier HTML de site" + uses: wildtechgarden/validator-html-action@main + with: + action-workspace: ${{ github.workspace }}/validate-html-action + use-existing-workspace: "true" +``` ## Développement diff --git a/README.md b/README.md index 2f42561..3bad605 100644 --- a/README.md +++ b/README.md @@ -10,18 +10,65 @@ CI Status: [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/w ## Contents 1. [Contents](#contents) -2. [Features](#features) -3. [Usage](#usage) -4. [Development](#development) -5. [Colophon](#colophon) +2. [Configuration and usage](#configuration-and-usage) + 1. [Actions inputs variables](#actions-inputs-variables) + 2. [Sample usage](#sample-usage) +3. [Development](#development) +4. [Colophon](#colophon) -## Features +## Configuration and usage -TBD +### Actions inputs variables -## Usage +| Input | Required | Default | Meaning | +|-------|-------|---------|---------| +| download-site-as | yes | unminified-site | GitHub Artifact containing a tarball with the site | +| download-site-filename | yes | hugo-site.tar | Name of tarball containing the site | +| output-directory | yes | public | subdirectory (in tarball) containing the site to validate | +| repo-token | yes | _(none)_ | GITHUB_TOKEN | +| use-existing-workspace | no | false | Use an existing checkout and built site instead of artifact | -TBD +The tarball (default ``hugo-site.tar``) in the artifact (default +``unminified-site``) pointed at by ``download-site-as`` must contain the +following: + +* A subdirectory tree containing the site (default: _public_, optionally +defined by ``output-directory``). + +### Sample usage + +```yaml +name: test-html-validate +on: + pull_request: + types: + - assigned + - opened + - synchronize + - reopened + push: + branches: + - main +jobs: + build-unminified-site: + runs-on: ubuntu-20.04 + steps: + - name: "Build site with Hugo and audit" + uses: wildtechgarden/audit-build-action-hugo-dfd@main + with: + base-url: "https://www.example.com/" + build-for-downstream: "true" + source-directory: exampleSite + use-lfs: false + - uses: actions/checkout@v3 + with: + path: validate-html-action + - name: "Validate HTML of statically generated website" + uses: wildtechgarden/validator-html-action@main + with: + action-workspace: ${{ github.workspace }}/validate-html-action + use-existing-workspace: "true" +``` ## Development diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..919ccf5 --- /dev/null +++ b/action.yml @@ -0,0 +1,83 @@ +--- +# yamllint disable rule:key-ordering +# cspell:ignore OUTPUTDIR endswith +name: DFD Validate HTML (Hugo) +author: Daniel F. Dickinson +description: Validate HTML and CSS of a static site +branding: + color: blue + icon: check-circle +inputs: + download-site-as: + description: Artifact containing the Hugo site + required: true + default: unminified-site + download-site-filename: + description: Filename for tarball of site to download from artifact + required: true + default: hugo-site.tar + output-directory: + description: Location of output site + required: true + default: public + repo-token: + description: GITHUB_TOKEN + required: true + use-existing-workspace: + description: Use an existing checkout and built site instead of artifact + required: false + default: "false" +runs: + using: composite + steps: + - uses: actions/download-artifact@v3 + if: inputs.use-existing-workspace != 'true' + with: + name: ${{ inputs.download-site-as }} + - name: Extract site and configs + if: inputs.use-existing-workspace != 'true' + shell: bash + env: + DOWNLOAD_SITE_FILENAME: ${{ inputs.download-site-filename }} + run: tar -xf "${DOWNLOAD_SITE_FILENAME}" + - name: Install Java + shell: bash + run: | + sudo apt-get update + sudo apt-get install default-jre + - name: Get validator + shell: bash + env: + GITHUB_WORKSPACE: ${{ github.workspace }} + # Avoid runner API rate-limiting + GH_TOKEN: ${{ inputs.repo-token }} + run: | + curl --header "Authorization: Bearer $GH_TOKEN" -o vnu.jar.zip -sL \ + $(curl --request GET --header "Accept: application/vnd.github+json" \ + --header "Authorization: Bearer $GH_TOKEN" -s --url \ + https://api.github.com/repos/validator/validator/releases/latest | jq -r \ + ". as \$artifacts | .tag_name as \$version | \ + \$artifacts | .assets | .[] | [.name, .browser_download_url] | \ + if (.[0] | contains(\$version) and contains(\"vnu.jar\") and \ + endswith(\"zip\")) \ + then .[1] \ + else empty \ + end") && unzip vnu.jar.zip && \ + mkdir -p jar && mv dist/vnu.jar jar/ && mv dist/index.html jar/ && \ + mv dist/README.md jar/ && rm -rf dist && rm -f vnu.jar.zip + - name: Validate site HTML + shell: bash + env: + OUTPUT_DIRECTORY: ${{ inputs.output-directory }} + # yamllint disable rule:line-length + run: | + java -jar jar/vnu.jar --Werror --skip-non-html ${OUTPUT_DIRECTORY} + - name: Validate site CSS + shell: bash + env: + OUTPUT_DIRECTORY: ${{ inputs.output-directory }} + # yamllint disable rule:line-length + run: | + java -jar jar/vnu.jar --skip-non-css --Werror ${OUTPUT_DIRECTORY} + # yamllint enable +... diff --git a/words-fr-project.txt b/words-fr-project.txt index 0733977..8398a5e 100644 --- a/words-fr-project.txt +++ b/words-fr-project.txt @@ -3,3 +3,14 @@ Commons Garden ShareAlike Wild +existing +false +hugo +hvm +tarball +assigned +opened +reopened +downstream +true +checkout