-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add ltex and actionlint * gh-hosted runnners * Add concurrency * No cwd
- Loading branch information
Showing
9 changed files
with
158 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Tests | ||
on: | ||
push: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
check_hooks: | ||
name: Check hooks work | ||
timeout-minutes: 15 | ||
runs-on: ubuntu-22.04 | ||
|
||
steps: | ||
- name: Clone repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install pre-commit | ||
run: | | ||
apk update && apk add python3 python3-dev py3-pip git go build-base | ||
pip install pre-commit --ignore-installed distlib | ||
pre-commit install --install-hooks | ||
- name: Run pre-commit hooks | ||
run: | | ||
pre-commit run --all-files --show-diff-on-failure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
repos: | ||
- repo: meta | ||
hooks: | ||
- id: check-hooks-apply | ||
- id: check-useless-excludes | ||
|
||
- repo: local | ||
hooks: | ||
- id: local_hooks | ||
name: All hooks are ran | ||
language: ruby | ||
entry: ./check_up_to_date.rb | ||
pass_filenames: false | ||
files: ^.pre-commit-(config|hooks)\.yaml$ | ||
|
||
- id: ltex | ||
name: LTeX grammar check | ||
language: script | ||
entry: ltex/ltex.sh | ||
verbose: true | ||
types_or: ['markdown', 'mdx'] | ||
args: [--client-configuration, ltex-config.json] | ||
|
||
- id: actionlint | ||
name: Lint github workflows | ||
language: golang | ||
additional_dependencies: | ||
- github.com/rhysd/actionlint/cmd/[email protected] | ||
entry: actionlint | ||
files: .github/workflows/.*\.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
- id: ltex | ||
name: LTeX grammar check | ||
language: script | ||
entry: ltex/ltex.sh | ||
verbose: true | ||
types_or: ['markdown', 'mdx'] | ||
|
||
- id: actionlint | ||
name: Lint github workflows | ||
language: golang | ||
additional_dependencies: | ||
- github.com/rhysd/actionlint/cmd/[email protected] | ||
entry: actionlint | ||
files: .github/workflows/.*\.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# pre-commit-hooks | ||
# Pennylane's pre-commit hooks | ||
|
||
Homemade pre-commit hooks |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#! /usr/bin/env ruby | ||
|
||
require 'yaml' | ||
|
||
hooks = YAML.safe_load_file('.pre-commit-hooks.yaml') | ||
local_config = YAML.safe_load_file('.pre-commit-config.yaml') | ||
.fetch('repos') | ||
.find { _1['repo'] == 'local' } | ||
.fetch('hooks')[1..] | ||
local_config.each { _1.delete('args') } | ||
|
||
raise "Update local configuration to include all hooks defined in this repo" unless hooks == local_config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"ltex": { | ||
"language": "en-US", | ||
"dictionary": { | ||
"en-US": [ | ||
"Pennylane" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM openjdk:11.0.16-jre | ||
|
||
ARG LTEX_VERSION=16.0.0 | ||
|
||
RUN <<EOF | ||
wget https://github.com/valentjn/ltex-ls/releases/download/${LTEX_VERSION}/ltex-ls-${LTEX_VERSION}.tar.gz -O - | tar -xz | ||
mv /ltex-ls-${LTEX_VERSION} /ltex-ls | ||
EOF | ||
|
||
ENTRYPOINT ["/ltex-ls/bin/ltex-cli"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#! /bin/bash | ||
|
||
set -euo pipefail | ||
|
||
[ -z "${CI+1}" ] || exit 0 | ||
|
||
ltex_dir=$(dirname "$0") | ||
ltex_version="" | ||
|
||
ltex_tag=$(cd $ltex_dir; tar -cf - ./ | md5sum | cut -d' ' -f1) | ||
ltex_version="ltex:$ltex_tag" | ||
|
||
( | ||
cd $ltex_dir | ||
docker inspect "$ltex_version" > /dev/null || docker build . -t "$ltex_version" -t 'ltex:latest' | ||
) | ||
|
||
files_to_clean=() | ||
files_to_process=() | ||
|
||
function cleanup() { | ||
if (( ${#files_to_clean[@]} )); then | ||
rm "${files_to_clean[@]}" | ||
fi | ||
} | ||
|
||
trap cleanup SIGHUP SIGINT SIGTERM | ||
|
||
for file in "$@"; do | ||
new_file=${file/%.mdx/.md} | ||
|
||
if [ "$file" != "$new_file" ]; then | ||
cp "$file" "$new_file" | ||
files_to_process+=( "$new_file" ) | ||
files_to_clean+=( "$new_file" ) | ||
else | ||
files_to_process+=( "$file" ) | ||
fi | ||
done | ||
|
||
echo "${files_to_process[@]}" | | ||
xargs docker run --rm -i \ | ||
--user "$UID" \ | ||
--volume "$(pwd):/src:rw,Z" \ | ||
--workdir /src \ | ||
"$ltex_version" | | ||
sed -E 's|(app/javascript/documentation/.*?\.md):|\1x:|g' || true | ||
|
||
cleanup | ||
|
||
exit 0 |