From 38d17cbdceba8e6f9c37697a3898efcb35bff14a Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Thu, 3 Aug 2023 00:25:20 -0700 Subject: [PATCH] make lint job reusable --- .github/workflows/build.yml | 25 ++++----------------- .github/workflows/lint.yml | 45 +++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e10894696..454b530fa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -100,27 +100,10 @@ jobs: secrets: inherit lint: - runs-on: ubuntu-latest - steps: - - name: Install Lua - run: | - sudo apt-get update - sudo apt-get install lua5.3 - - name: Clone DFHack - uses: actions/checkout@v3 - with: - submodules: true - - name: Check whitespace - run: python ci/lint.py --git-only --github-actions - - name: Check Authors.rst - if: always() - run: python ci/authors-rst.py - - name: Check for missing documentation - if: always() - run: python ci/script-docs.py - - name: Check Lua syntax - if: always() - run: python ci/script-syntax.py --ext=lua --cmd="luac5.3 -p" --github-actions + uses: ./.github/workflows/lint.yml + with: + dfhack_ref: ${{ github.ref }} + secrets: inherit check-pr: runs-on: ubuntu-latest diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..348068c0a --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,45 @@ +name: Lint + +on: + workflow_call: + inputs: + dfhack_ref: + type: string + required: true + scripts_ref: + type: string + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Install Lua + run: | + sudo apt-get update + sudo apt-get install lua5.3 + - name: Clone DFHack + uses: actions/checkout@v3 + with: + repository: 'DFHack/dfhack' + ref: ${{ inputs.dfhack_ref }} + - name: Get scripts submodule ref + if: '!inputs.scripts_ref' + id: scriptssubmoduleref + run: echo ref=$(git submodule | fgrep scripts | cut -c2-41) >> $GITHUB_OUTPUT + - name: Clone scripts + uses: actions/checkout@v3 + with: + repository: 'DFHack/scripts' + ref: ${{ inputs.scripts_ref || steps.scriptssubmoduleref.outputs.ref }} + path: scripts + - name: Check whitespace + run: python ci/lint.py --git-only --github-actions + - name: Check Authors.rst + if: always() + run: python ci/authors-rst.py + - name: Check for missing documentation + if: always() + run: python ci/script-docs.py + - name: Check Lua syntax + if: always() + run: python ci/script-syntax.py --ext=lua --cmd="luac5.3 -p" --github-actions