Fix PreCommitUpdate.yml #270
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
name: Test generated package | |
on: | |
push: | |
branches: | |
- main | |
tags: ["*"] | |
pull_request: | |
branches: | |
- main | |
paths: | |
- "src/**" | |
- "test/**" | |
- "*.toml" | |
- "copier.yml" | |
- "template/**" | |
- ".github/workflows/TestGeneratedPkg.yml" | |
types: [opened, synchronize, reopened] | |
workflow_dispatch: | |
jobs: | |
test-generated-pkg: | |
strategy: | |
fail-fast: false | |
matrix: | |
version: | |
- "lts" | |
- "1" | |
os: | |
- ubuntu-latest | |
arch: | |
- x64 | |
allow_failure: [false] | |
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} | |
runs-on: ${{ matrix.os }} | |
continue-on-error: ${{ matrix.allow_failure }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: julia-actions/setup-julia@v2 | |
with: | |
version: ${{ matrix.version }} | |
arch: ${{ matrix.arch }} | |
- name: Use Julia cache | |
uses: julia-actions/cache@v2 | |
- name: Build the package | |
uses: julia-actions/julia-buildpkg@v1 | |
- name: Install JuliaFormatter.jl | |
run: julia -e 'using Pkg; pkg"add JuliaFormatter"' | |
- name: Hack for setup-python cache # https://github.com/actions/setup-python/issues/807 | |
run: touch requirements.txt | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
cache: "pip" | |
python-version: "3.11" | |
- name: Hack for setup-python cache # https://github.com/actions/setup-python/issues/807 | |
run: rm requirements.txt | |
- name: Cache pre-commit | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pre-commit | |
key: ${{ runner.os }}-pre-commit-${{ hashFiles('**/.pre-commit-config.yaml') }} | |
- name: Install pre-commit | |
run: pip install pre-commit | |
# Actual tests | |
- name: Create a package using the template with default values | |
run: | | |
julia --project=. --eval ' | |
using BestieTemplate, UUIDs; | |
data = Dict( | |
"PackageName" => "Guldasta", | |
"PackageUUID" => string(UUIDs.uuid4()), | |
"PackageOwner" => "Bagicha", | |
"Authors" => "Mali <[email protected]>" | |
); | |
BestieTemplate.generate( | |
pkgdir(BestieTemplate), | |
"tmp/Guldasta.jl", | |
data; | |
defaults = true, | |
quiet = true, | |
vcs_ref="HEAD" | |
); | |
' | |
- name: Run the tests in the generated package | |
run: | | |
julia --project=tmp/Guldasta.jl --eval 'using Pkg; Pkg.test()' | |
- name: Build the docs of the generated package | |
run: | | |
julia --project=tmp/Guldasta.jl/docs --eval 'using Pkg; pkg"dev tmp/Guldasta.jl"' \ | |
-L tmp/Guldasta.jl/docs/make.jl | |
- name: Check that the docs wre properly generated | |
run: | | |
./.github/scripts/check-docs.bash tmp/Guldasta.jl | |
- name: Check that all pre-commit checks pass | |
shell: bash {0} # The default shell uses -e which checks intermediary failures | |
run: | | |
cd tmp/Guldasta.jl | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub action" | |
git init | |
git add . | |
git commit -m "First commit" | |
# Failures here can be due to whitespace management in Jinja | |
SKIP=no-commit-to-branch pre-commit run -a |