From 0765615ed87c85936995aed4acfbfcaddc123082 Mon Sep 17 00:00:00 2001 From: Joseph Kato Date: Fri, 22 Mar 2024 15:00:05 -0700 Subject: [PATCH] Move to Actions --- .circleci/config.yml | 52 ------------------- .github/workflows/main.yml | 46 ++++++++++++++++ .gitignore | 3 ++ Makefile | 12 +++++ README.md | 7 +++ testdata/.vale.ini | 6 +++ .../{shortcodes/test.md => shortcodes.md} | 11 ++++ testdata/shortcodes/.vale.ini | 12 ----- testdata/test.ct | 40 +++++++------- 9 files changed, 107 insertions(+), 82 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/main.yml create mode 100644 Makefile create mode 100644 testdata/.vale.ini rename testdata/{shortcodes/test.md => shortcodes.md} (93%) delete mode 100644 testdata/shortcodes/.vale.ini diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 1d95d2a..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,52 +0,0 @@ -# Use the latest 2.1 version of CircleCI pipeline process engine. -# See: https://circleci.com/docs/2.0/configuration-reference -version: 2.1 - -# Define a job to be invoked later in a workflow. -# See: https://circleci.com/docs/2.0/configuration-reference/#jobs -jobs: - build: - working_directory: ~/repo - # Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub. - # See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor - docker: - - image: circleci/golang:1.17 - # Add steps to the job - # See: https://circleci.com/docs/2.0/configuration-reference/#steps - steps: - - checkout - - - restore_cache: - keys: - - go-mod-v4-{{ checksum "go.sum" }} - - - run: - name: Install Dependencies - command: go mod download - - - run: - name: Fetch Vale - command: | - wget https://github.com/errata-ai/vale/releases/download/v3.0.5/vale_3.0.5_Linux_64-bit.tar.gz - mkdir bin && tar -xvzf vale_3.0.5_Linux_64-bit.tar.gz -C bin - echo 'PATH=./bin:"$PATH"' >> $BASH_ENV - - save_cache: - key: go-mod-v4-{{ checksum "go.sum" }} - paths: - - "/go/pkg/mod" - - - run: - name: Run tests - command: | - mkdir -p /tmp/test-reports - gotestsum --junitfile /tmp/test-reports/unit-tests.xml - - store_test_results: - path: /tmp/test-reports - -# Invoke jobs via workflows -# See: https://circleci.com/docs/2.0/configuration-reference/#workflows -workflows: - sample: # This is the name of the workflow, feel free to change it to better match your workflow. - # Inside the workflow, you define the jobs you want to run. - jobs: - - build diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..34e82b4 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,46 @@ +name: Build + Test + +on: [push, pull_request] + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - run: zip -r Hugo.zip Hugo -x "*.DS_Store" + + - name: Upload style to release + uses: svenstaro/upload-release-action@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: Hugo.zip + + cucumber: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Go + uses: actions/setup-go@v5 + + - name: Install Deps + run: | + wget https://github.com/errata-ai/vale/releases/download/v${VALE_VERSION}/vale_${VALE_VERSION}_Linux_64-bit.tar.gz + mkdir bin && tar -xvzf vale_${VALE_VERSION}_Linux_64-bit.tar.gz -C bin + echo "./bin" >> $GITHUB_PATH + env: + VALE_VERSION: 3.3.0 + + - name: Features + run: make test + + - name: Integration + run: vale README.md diff --git a/.gitignore b/.gitignore index 66fd13c..6c5b1a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +Hugo.zip +/testdata/styles + # Binaries for programs and plugins *.exe *.exe~ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..cd33e18 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +.PHONY: test zip sync + +all: test + +zip: + zip -r Hugo.zip Hugo -x "*.DS_Store" + +sync: + cd testdata && vale sync && cd - + +test: zip sync + go test -v ./... diff --git a/README.md b/README.md index 7c11b7d..93d6a18 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,9 @@ # Hugo + A Vale configuration for Hugo-generated static sites. + +## Testing + +``` +$ make test +``` diff --git a/testdata/.vale.ini b/testdata/.vale.ini new file mode 100644 index 0000000..6d6ebd5 --- /dev/null +++ b/testdata/.vale.ini @@ -0,0 +1,6 @@ +StylesPath = styles + +Packages = ../Hugo.zip + +[*.md] +BasedOnStyles = Vale diff --git a/testdata/shortcodes/test.md b/testdata/shortcodes.md similarity index 93% rename from testdata/shortcodes/test.md rename to testdata/shortcodes.md index 72798a6..79a6e09 100644 --- a/testdata/shortcodes/test.md +++ b/testdata/shortcodes.md @@ -68,3 +68,14 @@ For example: - {{}} - {{%/* commentedoutshortcodemd */%}} - {{%/* /closecommentedoutshortcodemd */%}} + +The unspalsh shortcode: + +{{% unsplash name="xxx" href="xxx" %}} + +Another unspalsh shortcode: + +{{% unsplash + name="xxx" + href="xxx" +%}} diff --git a/testdata/shortcodes/.vale.ini b/testdata/shortcodes/.vale.ini deleted file mode 100644 index d958535..0000000 --- a/testdata/shortcodes/.vale.ini +++ /dev/null @@ -1,12 +0,0 @@ -[*.md] -BasedOnStyles = Vale - -# Exclude `{{< ... >}}`, `{{% ... %}}`, [Who]({{< ... >}}) -TokenIgnores = ({{[%<](?:/\*)? .* (?:\*/)?[%>]}}.*?{{[%<](?:/\*| )?/.* (?:\*/)?[%>]}}), \ -(\[.+\]\({{<(?:/\*)? .+ (?:\*/)?>}}\)), \ -({{[%<](?:/\*)? .+ (?:\*/)?[%>]}}) - -# Exclude `{{< myshortcode `This is some HTML, ... >}}` -BlockIgnores = (?sm)^({{[%<](?:/\*)? [^{]*? (?:\*/)?[%>]}})\n$, \ -(?s) *({{<(?:/\*)? highlight [^>]*(?:\*/| )?>}}.*?{{<(?:/\*| )?/ ?highlight (?:\*/)?>}}), \ -({{[%<](?:/\*)? .+ (?:\*/)?[%>]}}) diff --git a/testdata/test.ct b/testdata/test.ct index ecc5849..6cd3d7e 100644 --- a/testdata/test.ct +++ b/testdata/test.ct @@ -1,18 +1,22 @@ -$ cdf ${ROOTDIR}/shortcodes -$ vale --config .vale.ini --output=line --sort --normalize --relative --no-exit test.md -test.md:1:3:Vale.Spelling:Did you really mean 'Shortcodes'? -test.md:3:3:Vale.Spelling:Did you really mean 'Shortcodes'? -test.md:8:1:Vale.Spelling:Did you really mean 'Shortcodes'? -test.md:12:1:Vale.Spelling:Did you really mean 'Shortcodes'? -test.md:17:1:Vale.Spelling:Did you really mean 'Shortcodes'? -test.md:21:1:Vale.Spelling:Did you really mean 'Shortcodes'? -test.md:25:1:Vale.Spelling:Did you really mean 'Shortcodes'? -test.md:38:1:Vale.Spelling:Did you really mean 'Shortcodes'? -test.md:42:1:Vale.Spelling:Did you really mean 'Shortcodes'? -test.md:46:1:Vale.Spelling:Did you really mean 'hidecaption'? -test.md:50:1:Vale.Spelling:Did you really mean 'Shortcodes'? -test.md:54:1:Vale.Spelling:Did you really mean 'Shortcodes'? -test.md:58:1:Vale.Spelling:Did you really mean 'Shortcodes'? -test.md:60:1:Vale.Spelling:Did you really mean 'Shortcodes'? -test.md:62:1:Vale.Spelling:Did you really mean 'Shortcodes'? -test.md:64:11:Vale.Spelling:Did you really mean 'shortcodes'? +$ cdf ${ROOTDIR} +$ vale --output=line --sort --normalize --relative --no-exit --no-global shortcodes.md +shortcodes.md:1:3:Vale.Spelling:Did you really mean 'Shortcodes'? +shortcodes.md:3:3:Vale.Spelling:Did you really mean 'Shortcodes'? +shortcodes.md:8:1:Vale.Spelling:Did you really mean 'Shortcodes'? +shortcodes.md:12:1:Vale.Spelling:Did you really mean 'Shortcodes'? +shortcodes.md:17:1:Vale.Spelling:Did you really mean 'Shortcodes'? +shortcodes.md:21:1:Vale.Spelling:Did you really mean 'Shortcodes'? +shortcodes.md:25:1:Vale.Spelling:Did you really mean 'Shortcodes'? +shortcodes.md:38:1:Vale.Spelling:Did you really mean 'Shortcodes'? +shortcodes.md:42:1:Vale.Spelling:Did you really mean 'Shortcodes'? +shortcodes.md:46:1:Vale.Spelling:Did you really mean 'hidecaption'? +shortcodes.md:50:1:Vale.Spelling:Did you really mean 'Shortcodes'? +shortcodes.md:54:1:Vale.Spelling:Did you really mean 'Shortcodes'? +shortcodes.md:58:1:Vale.Spelling:Did you really mean 'Shortcodes'? +shortcodes.md:60:1:Vale.Spelling:Did you really mean 'Shortcodes'? +shortcodes.md:62:1:Vale.Spelling:Did you really mean 'Shortcodes'? +shortcodes.md:64:11:Vale.Spelling:Did you really mean 'shortcodes'? +shortcodes.md:72:5:Vale.Spelling:Did you really mean 'unspalsh'? +shortcodes.md:72:14:Vale.Spelling:Did you really mean 'shortcode'? +shortcodes.md:76:9:Vale.Spelling:Did you really mean 'unspalsh'? +shortcodes.md:76:18:Vale.Spelling:Did you really mean 'shortcode'?