Merge pull request #3621 from myk002/myk_reusable

make jobs reusable for other repos
develop
Myk 2023-08-03 01:31:39 -07:00 committed by GitHub
commit 1702c5e364
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 169 additions and 100 deletions

@ -3,9 +3,12 @@ name: Build linux64
on:
workflow_call:
inputs:
ref:
dfhack_ref:
type: string
scripts_ref:
type: string
structures_ref:
type: string
default: ''
artifact-name:
type: string
append-date-and-hash:
@ -62,9 +65,24 @@ jobs:
- name: Clone DFHack
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
repository: 'DFHack/dfhack'
ref: ${{ inputs.dfhack_ref }}
submodules: true
fetch-depth: ${{ !inputs.platform-files && 1 || 0 }}
- name: Clone scripts
if: inputs.scripts_ref
uses: actions/checkout@v3
with:
repository: 'DFHack/scripts'
ref: ${{ inputs.scripts_ref }}
path: scripts
- name: Clone structures
if: inputs.structures_ref
uses: actions/checkout@v3
with:
repository: 'DFHack/df-structures'
ref: ${{ inputs.structures_ref }}
path: library/xml
- name: Fetch ccache
if: inputs.platform-files
uses: actions/cache/restore@v3
@ -116,8 +134,7 @@ jobs:
- name: Format artifact name
if: inputs.append-date-and-hash
id: artifactname
run: |
echo name=${{ inputs.artifact-name }}-$(date +%Y%m%d)-$(git rev-parse --short HEAD) >> $GITHUB_OUTPUT
run: echo name=${{ inputs.artifact-name }}-$(date +%Y%m%d)-$(git rev-parse --short HEAD) >> $GITHUB_OUTPUT
- name: Upload artifact
if: inputs.artifact-name
uses: actions/upload-artifact@v3

@ -3,9 +3,10 @@ name: Build win64
on:
workflow_call:
inputs:
ref:
dfhack_ref:
type: string
structures_ref:
type: string
default: ''
artifact-name:
type: string
append-date-and-hash:
@ -36,9 +37,16 @@ jobs:
- name: Clone DFHack
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
ref: ${{ inputs.dfhack_ref }}
submodules: true
fetch-depth: 0
- name: Clone structures
if: inputs.structures_ref
uses: actions/checkout@v3
with:
repository: 'DFHack/df-structures'
ref: ${{ inputs.structures_ref }}
path: library/xml
- name: Get 3rd party SDKs
if: inputs.launchdf
uses: actions/checkout@v3

@ -3,73 +3,9 @@ name: Build
on: [push, pull_request]
jobs:
build-linux:
name: Linux gcc-${{ matrix.gcc }}
uses: ./.github/workflows/build-linux.yml
with:
artifact-name: test-gcc-${{ matrix.gcc }}
cache-id: test
stonesense: ${{ matrix.plugins == 'all' }}
extras: ${{ matrix.plugins == 'all' }}
gcc-ver: ${{ matrix.gcc }}
test:
uses: ./.github/workflows/test.yml
secrets: inherit
strategy:
fail-fast: false
matrix:
include:
- gcc: 10
plugins: "default"
- gcc: 12
plugins: "all"
test-linux:
name: Test (Linux, GCC ${{ matrix.gcc }}, ${{ matrix.plugins }} plugins)
needs: build-linux
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- gcc: 10
plugins: "default"
- gcc: 12
plugins: "all"
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: test-gcc-${{ matrix.gcc }}
# - name: Fetch DF cache
# uses: actions/cache@v3
# with:
# path: ~/DF
# key: df-${{ hashFiles('ci/download-df.sh') }}
# - name: Download DF
# run: |
# sh ci/download-df.sh
# - name: Run lua tests
# id: run_tests_lua
# run: |
# export TERM=dumb
# status=0
# script -qe -c "python ci/run-tests.py --headless --keep-status \"$DF_FOLDER\"" || status=$((status + 1))
# python ci/check-rpc.py "$DF_FOLDER/dfhack-rpc.txt" || status=$((status + 2))
# mkdir -p artifacts
# cp "$DF_FOLDER"/test*.json "$DF_FOLDER"/*.log artifacts || status=$((status + 4))
# exit $status
# - name: Upload test artifacts
# uses: actions/upload-artifact@v3
# if: (success() || failure()) && steps.run_tests.outcome != 'skipped'
# continue-on-error: true
# with:
# name: test-artifacts-${{ matrix.gcc }}
# path: artifacts
# - name: Clean up DF folder
# # prevent DFHack-generated files from ending up in the cache
# # (download-df.sh also removes them, this is just to save cache space)
# if: success() || failure()
# run: |
# rm -rf "$DF_FOLDER"
package-linux:
name: Linux package
@ -100,27 +36,8 @@ 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
secrets: inherit
check-pr:
runs-on: ubuntu-latest

@ -17,7 +17,7 @@ jobs:
uses: ./.github/workflows/build-windows.yml
with:
artifact-name: win64-release
ref: ${{ github.event.inputs && github.event.inputs.ref || github.event.ref }}
dfhack_ref: ${{ github.event.inputs && github.event.inputs.ref || github.event.ref }}
cache-id: release
cache-readonly: true
launchdf: true
@ -28,7 +28,7 @@ jobs:
uses: ./.github/workflows/build-linux.yml
with:
artifact-name: linux64-release
ref: ${{ github.event.inputs && github.event.inputs.ref || github.event.ref }}
dfhack_ref: ${{ github.event.inputs && github.event.inputs.ref || github.event.ref }}
cache-id: release
cache-readonly: true
stonesense: true

@ -0,0 +1,44 @@
name: Lint
on:
workflow_call:
inputs:
dfhack_ref:
type: string
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

@ -28,7 +28,7 @@ jobs:
uses: ./.github/workflows/build-linux.yml
with:
artifact-name: common-depot
ref: ${{ github.event.inputs && github.event.inputs.ref || github.event.ref }}
dfhack_ref: ${{ github.event.inputs && github.event.inputs.ref || github.event.ref }}
platform-files: false
docs: true
stonesense: true
@ -39,7 +39,7 @@ jobs:
uses: ./.github/workflows/build-windows.yml
with:
artifact-name: win64-depot
ref: ${{ github.event.inputs && github.event.inputs.ref || github.event.ref }}
dfhack_ref: ${{ github.event.inputs && github.event.inputs.ref || github.event.ref }}
cache-id: release
cache-readonly: true
common-files: false
@ -51,7 +51,7 @@ jobs:
uses: ./.github/workflows/build-linux.yml
with:
artifact-name: linux64-depot
ref: ${{ github.event.inputs && github.event.inputs.ref || github.event.ref }}
dfhack_ref: ${{ github.event.inputs && github.event.inputs.ref || github.event.ref }}
cache-id: release
cache-readonly: true
common-files: false

@ -0,0 +1,83 @@
name: Test
on:
workflow_call:
inputs:
dfhack_ref:
type: string
scripts_ref:
type: string
structures_ref:
type: string
jobs:
build-linux:
name: Linux gcc-${{ matrix.gcc }}
uses: ./.github/workflows/build-linux.yml
with:
dfhack_ref: ${{ inputs.dfhack_ref }}
scripts_ref: ${{ inputs.scripts_ref }}
structures_ref: ${{ inputs.structures_ref }}
artifact-name: test-gcc-${{ matrix.gcc }}
cache-id: test
stonesense: ${{ matrix.plugins == 'all' }}
extras: ${{ matrix.plugins == 'all' }}
gcc-ver: ${{ matrix.gcc }}
secrets: inherit
strategy:
fail-fast: false
matrix:
include:
- gcc: 10
plugins: "default"
- gcc: 12
plugins: "all"
test-linux:
name: Test (Linux, GCC ${{ matrix.gcc }}, ${{ matrix.plugins }} plugins)
needs: build-linux
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- gcc: 10
plugins: "default"
- gcc: 12
plugins: "all"
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: test-gcc-${{ matrix.gcc }}
# - name: Fetch DF cache
# uses: actions/cache@v3
# with:
# path: ~/DF
# key: df-${{ hashFiles('ci/download-df.sh') }}
# - name: Download DF
# run: |
# sh ci/download-df.sh
# - name: Run lua tests
# id: run_tests_lua
# run: |
# export TERM=dumb
# status=0
# script -qe -c "python ci/run-tests.py --headless --keep-status \"$DF_FOLDER\"" || status=$((status + 1))
# python ci/check-rpc.py "$DF_FOLDER/dfhack-rpc.txt" || status=$((status + 2))
# mkdir -p artifacts
# cp "$DF_FOLDER"/test*.json "$DF_FOLDER"/*.log artifacts || status=$((status + 4))
# exit $status
# - name: Upload test artifacts
# uses: actions/upload-artifact@v3
# if: (success() || failure()) && steps.run_tests.outcome != 'skipped'
# continue-on-error: true
# with:
# name: test-artifacts-${{ matrix.gcc }}
# path: artifacts
# - name: Clean up DF folder
# # prevent DFHack-generated files from ending up in the cache
# # (download-df.sh also removes them, this is just to save cache space)
# if: success() || failure()
# run: |
# rm -rf "$DF_FOLDER"