Skip to content

Commit

Permalink
ci: 简化lint环境的安装
Browse files Browse the repository at this point in the history
使用latexindent不必安装texlive。
同时分离lint与test的workflow。
  • Loading branch information
OopsYao committed Mar 2, 2021
1 parent 22a751d commit fe4d017
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 103 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Lint
on:
pull_request:
branches: main

jobs:
lint:
name: Lint code
runs-on: ubuntu-18.04
env:
cache-version: v20210203.1
steps:
- name: Checkout
uses: actions/[email protected]
- name: Cache
id: cache
uses: actions/[email protected]
with:
path: |
latexindent
/opt/hostedtoolcache/perl
key: lint-${{ runner.os }}-${{ env.cache-version }}
- name: Install latexindent
if: steps.cache.outputs.cache-hit != 'true'
run: source ci/latexindent-install.sh
- name: Setup Perl environment (for cpanm)
uses: shogo82148/[email protected]
- name: Install Perl dependencies
run: source ci/latexindent-deps-install.sh
- name: Check format
run: source ci/latexindent.sh
9 changes: 0 additions & 9 deletions .github/workflows/perl-modules

This file was deleted.

48 changes: 1 addition & 47 deletions .github/workflows/ci.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,11 @@
name: CI
name: Test
on:
push:
branches: main
pull_request:
branches: main

jobs:
lint:
name: Lint
runs-on: ubuntu-18.04
if: "!contains(github.event.head_commit.message, '[skip ci]')"
env:
cache-version: v20210203.1
steps:
- name: Checkout
uses: actions/[email protected]
- name: Set up PATH
run: echo "/tmp/texlive/bin/x86_64-linux" >> $GITHUB_PATH
- name: Cache
id: cache
uses: actions/[email protected]
with:
path: |
/tmp/texlive
/opt/hostedtoolcache/perl
key: ${{ runner.os }}-texlive-${{ hashFiles('.github/workflows/perl-modules') }}-${{ env.cache-version }}
- name: Download install-tl.zip
if: steps.cache.outputs.cache-hit != 'true'
run: |
curl -sOL http://mirror.ctan.org/systems/texlive/tlnet/install-tl.zip
unzip -q install-tl.zip
mv install-tl-2* install-tl-dir
- name: Run install-tl
if: steps.cache.outputs.cache-hit != 'true'
run: install-tl-dir/install-tl --profile .github/workflows/texlive-linux.profile
- name: Run tlmgr install
if: steps.cache.outputs.cache-hit != 'true'
run: |
tlmgr update --self
tlmgr install latex-bin latexindent
- name: Setup Perl environment
uses: shogo82148/[email protected]
- name: Install some other perl dependencies
run: cpanm $(cat .github/workflows/perl-modules)
- name: Check format
run: |
set -e
for f in $(find -name '*.tex' \
-or -name '*.cls' \
-or -name '*.bib'); do
latexindent -l "$f" | diff "$f" -
done
# CTAN没有一个提供像npm那样的依赖管理机制,
# 个人觉得这样宽松的依赖下进行l3build严格的对比机制不是太合理的
# 也许前一天能通过的测试,第二天由于依赖的包更新就无法通过了
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/texlive-linux.profile

This file was deleted.

37 changes: 0 additions & 37 deletions .github/workflows/texlive-packages

This file was deleted.

5 changes: 5 additions & 0 deletions ci/latexindent-deps-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env sh

set -ev

echo Y | latexindent/latexindent-module-installer.pl
6 changes: 6 additions & 0 deletions ci/latexindent-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh

set -ev

curl -sOL http://mirrors.ctan.org/support/latexindent.zip
unzip -q latexindent.zip
11 changes: 11 additions & 0 deletions ci/latexindent.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env sh

set -ev

for f in $(find \
-path ./latexindent -prune -false \
-or -name '*.tex' \
-or -name '*.cls' \
-or -name '*.bib'); do
latexindent/latexindent.pl -l "$f" | diff "$f" -
done

0 comments on commit fe4d017

Please sign in to comment.