Skip to content

Commit

Permalink
CI stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
evilfactory committed Sep 21, 2024
1 parent 81ecaf1 commit cb99b19
Show file tree
Hide file tree
Showing 17 changed files with 287 additions and 139 deletions.
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# yaml-language-server: $schema=https://json.schemastore.org/dependabot-2.0.json

version: 2
updates:
- package-ecosystem: github-actions
target-branch: develop
directory: /
schedule:
interval: daily
21 changes: 21 additions & 0 deletions .github/workflows/harden-ci-security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json

name: Harden CI security

on:
workflow_call:
inputs:
target:
required: true
type: string

jobs:
ensure-sha-pinned-actions:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
ref: ${{ inputs.target }}
- name: Ensure all actions are pinned to a specific commit
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@3c16e895bb662b4d7e284f032cbe8835a57773cc # v3.0.11
118 changes: 118 additions & 0 deletions .github/workflows/update-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json

name: Update documentation

on:
workflow_dispatch:

env:
CI_DEPLOY_DIR: luacs-docs/ci-deploy
CI_ARTIFACTS_DIR: luacs-docs/ci-artifacts
DOCS_LUA_ROOT: luacs-docs/lua
DOCS_CS_ROOT: luacs-docs/cs
DOCS_LANDINGPAGE_ROOT: luacs-docs/landing-page

jobs:
update-docs-lua:
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
submodules: recursive

- name: Setup .NET
uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # v4.0.1
with:
dotnet-version: |
6.0.x
- uses: leafo/gh-actions-lua@35bcb06abec04ec87df82e08caa84d545348536e # v10.0.0
with:
luaVersion: "5.2"

- uses: leafo/gh-actions-luarocks@e65774a6386cb4f24e293dca7fc4ff89165b64c5 # v4.3.0

- name: Run install script
working-directory: ${{ env.DOCS_LUA_ROOT }}
run: ./scripts/install.sh

- name: Run docs generator script
working-directory: ${{ env.DOCS_LUA_ROOT }}
run: ./scripts/generate_docs.sh

- name: Run build script
working-directory: ${{ env.DOCS_LUA_ROOT }}
run: ./scripts/build.sh

- name: Create tarball
run: |
mkdir -p "$CI_ARTIFACTS_DIR"
tar -czf "$CI_ARTIFACTS_DIR"/lua.tar.gz -C "$DOCS_LUA_ROOT"/build .
- name: Upload tarball
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
with:
name: docs-lua
path: ${{ env.CI_ARTIFACTS_DIR }}/lua.tar.gz

update-docs-cs:
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Install doxygen
run: sudo apt-get update && sudo apt-get install -y doxygen

- name: Run build script
working-directory: ${{ env.DOCS_CS_ROOT }}
run: ./scripts/build.sh

- name: Create tarball
run: |
mkdir -p "$CI_ARTIFACTS_DIR"
tar -czf "$CI_ARTIFACTS_DIR"/cs.tar.gz -C "$DOCS_CS_ROOT"/build .
- name: Upload tarball
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
with:
name: docs-cs
path: ${{ env.CI_ARTIFACTS_DIR }}/cs.tar.gz

deploy-docs:
runs-on: ubuntu-latest
needs: [update-docs-lua, update-docs-cs]
steps:
- name: Checkout branch
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- run: mkdir -p "$CI_ARTIFACTS_DIR" "$CI_DEPLOY_DIR"

- name: "Download build artifacts: lua docs"
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: docs-lua
path: ${{ env.CI_ARTIFACTS_DIR }}

- name: "Download build artifacts: cs docs"
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: docs-cs
path: ${{ env.CI_ARTIFACTS_DIR }}

- name: Extract lua and cs tarballs
run: |
mkdir -p "$CI_DEPLOY_DIR"/{lua,cs}-docs
tar -xzf "$CI_ARTIFACTS_DIR"/lua.tar.gz -C "$CI_DEPLOY_DIR"/lua-docs
tar -xzf "$CI_ARTIFACTS_DIR"/cs.tar.gz -C "$CI_DEPLOY_DIR"/cs-docs
- name: Copy landing page files
run: cp -r "$DOCS_LANDINGPAGE_ROOT"/. "$CI_DEPLOY_DIR"

- name: Deploy
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e #v4.0.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ${{ env.CI_DEPLOY_DIR }}
keep_files: true
52 changes: 26 additions & 26 deletions luacs-docs/cs/scripts/build.ps1
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
Import-Module -DisableNameChecking $PSScriptRoot/../../scripts/location.psm1

try {
Change-Location $PSScriptRoot/..
Change-Location $PSScriptRoot/..

if ((Get-Command "doxygen" -ErrorAction SilentlyContinue) -eq $null) {
echo "doxygen not found"
exit 1
}
if ((Get-Command "doxygen" -ErrorAction SilentlyContinue) -eq $null) {
echo "doxygen not found"
exit 1
}

Remove-Item -Force -Recurse ./build | Out-Null
New-Item -ItemType Directory ./build | Out-Null
New-Item -ItemType Directory ./build/baro-server | Out-Null
New-Item -ItemType Directory ./build/baro-client | Out-Null
Remove-Item -Force -Recurse ./build | Out-Null
New-Item -ItemType Directory ./build | Out-Null
New-Item -ItemType Directory ./build/baro-server | Out-Null
New-Item -ItemType Directory ./build/baro-client | Out-Null

echo "Building server docs"
try {
Change-Location ./baro-server
doxygen ./Doxyfile
} finally {
Restore-Location
}
echo "Building server docs"
try {
Change-Location ./baro-server
doxygen ./Doxyfile
} finally {
Restore-Location
}

echo "Building client docs"
try {
Change-Location ./baro-client
doxygen ./Doxyfile
} finally {
Restore-Location
}
echo "Building client docs"
try {
Change-Location ./baro-client
doxygen ./Doxyfile
} finally {
Restore-Location
}

echo "Building shared docs"
doxygen ./Doxyfile
echo "Building shared docs"
doxygen ./Doxyfile
} finally {
Restore-Location
Restore-Location
}
14 changes: 7 additions & 7 deletions luacs-docs/cs/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
cd "$DIR/.."

if ! command -v "doxygen" &> /dev/null; then
echo "doxygen not found"
exit 1
if ! command -v "doxygen" &>/dev/null; then
echo "doxygen not found"
exit 1
fi

rm -rf ./build
Expand All @@ -15,14 +15,14 @@ mkdir -p ./build/baro-client

echo "Building server docs"
(
cd ./baro-server
doxygen ./Doxyfile
cd ./baro-server
doxygen ./Doxyfile
)

echo "Building client docs"
(
cd ./baro-client
doxygen ./Doxyfile
cd ./baro-client
doxygen ./Doxyfile
)

echo "Building shared docs"
Expand Down
22 changes: 11 additions & 11 deletions luacs-docs/cs/scripts/serve.ps1
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
Import-Module -DisableNameChecking $PSScriptRoot/../../scripts/location.psm1

try {
Change-Location $PSScriptRoot/..
Change-Location $PSScriptRoot/..

if ((Get-Command "python3" -ErrorAction SilentlyContinue) -eq $null) {
echo "python3 not found"
exit 1
}
if ((Get-Command "python3" -ErrorAction SilentlyContinue) -eq $null) {
echo "python3 not found"
exit 1
}

python3 ../scripts/http_server.py ./build `
--port 8001 `
--route /:html `
--route /baro-client:baro-client `
--route /baro-server:baro-server
python3 ../scripts/http_server.py ./build `
--port 8001 `
--route /:html `
--route /baro-client:baro-client `
--route /baro-server:baro-server
} finally {
Restore-Location
Restore-Location
}
14 changes: 7 additions & 7 deletions luacs-docs/cs/scripts/serve.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
cd "$DIR/.."

if ! command -v "python3" &> /dev/null; then
echo "python3 not found"
exit 1
if ! command -v "python3" &>/dev/null; then
echo "python3 not found"
exit 1
fi

python3 ../scripts/http_server.py ./build \
--port 8001 \
--route /:html \
--route /baro-client:baro-client \
--route /baro-server:baro-server
--port 8001 \
--route /:html \
--route /baro-client:baro-client \
--route /baro-server:baro-server
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="../../../../Barotrauma/BarotraumaClient/LinuxClient.csproj" PrivateAssets="false">
<ProjectReference Include="../../../../LuaCsForBarotrauma/Barotrauma/BarotraumaClient/LinuxClient.csproj" PrivateAssets="false">
<Private></Private>
<Aliases>BarotraumaClient</Aliases>
</ProjectReference>
<ProjectReference Include="../../../../Barotrauma\BarotraumaServer\LinuxServer.csproj">
<ProjectReference Include="../../../../LuaCsForBarotrauma/Barotrauma\BarotraumaServer\LinuxServer.csproj">
<Aliases>BarotraumaServer</Aliases>
</ProjectReference>
<ProjectReference Include="../../../../Libraries/Farseer Physics Engine 3.5/Farseer.NetStandard.csproj" PrivateAssets="false" />
<ProjectReference Include="../../../../LuaCsForBarotrauma/Libraries/Farseer Physics Engine 3.5/Farseer.NetStandard.csproj" PrivateAssets="false" />
</ItemGroup>
</Project>
8 changes: 4 additions & 4 deletions luacs-docs/lua/scripts/LuaDocsGenerator/LuaDocsGenerator.sln
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33122.133
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LinuxClient", "..\..\..\..\Barotrauma\BarotraumaClient\LinuxClient.csproj", "{426071C4-6668-4CF9-A44C-5FBEB72C469B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LinuxClient", "..\..\..\..\LuaCsForBarotrauma\Barotrauma\BarotraumaClient\LinuxClient.csproj", "{426071C4-6668-4CF9-A44C-5FBEB72C469B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Farseer.NetStandard", "..\..\..\..\Libraries\Farseer Physics Engine 3.5\Farseer.NetStandard.csproj", "{F8F85D52-11B5-4177-914C-9AC75345D089}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Farseer.NetStandard", "..\..\..\..\LuaCsForBarotrauma\Libraries\Farseer Physics Engine 3.5\Farseer.NetStandard.csproj", "{F8F85D52-11B5-4177-914C-9AC75345D089}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LinuxServer", "..\..\..\..\Barotrauma\BarotraumaServer\LinuxServer.csproj", "{562EDFE0-7AEB-4F1E-BC26-148DF42F4186}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LinuxServer", "..\..\..\..\LuaCsForBarotrauma\Barotrauma\BarotraumaServer\LinuxServer.csproj", "{562EDFE0-7AEB-4F1E-BC26-148DF42F4186}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LuaDocsGenerator", "LuaDocsGenerator.csproj", "{6E36A474-29B7-4F0C-96CE-79F11BF6C0A4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BarotraumaCore", "..\..\..\..\Libraries\BarotraumaLibs\BarotraumaCore\BarotraumaCore.csproj", "{4F493ED0-CC77-4151-AFBC-A12340B352B7}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BarotraumaCore", "..\..\..\..\LuaCsForBarotrauma\Libraries\BarotraumaLibs\BarotraumaCore\BarotraumaCore.csproj", "{4F493ED0-CC77-4151-AFBC-A12340B352B7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
22 changes: 11 additions & 11 deletions luacs-docs/lua/scripts/build.ps1
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
Import-Module -DisableNameChecking $PSScriptRoot/../../scripts/location.psm1

try {
Change-Location $PSScriptRoot/..
Change-Location $PSScriptRoot/..

Remove-Item -Force -Recurse ./build | Out-Null
New-Item -ItemType Directory ./build | Out-Null
Copy-Item -Path ./css/* -Destination ./build -Recurse -Force | Out-Null
Copy-Item -Path ./js/* -Destination ./build -Recurse -Force | Out-Null
Remove-Item -Force -Recurse ./build | Out-Null
New-Item -ItemType Directory ./build | Out-Null
Copy-Item -Path ./css/* -Destination ./build -Recurse -Force | Out-Null
Copy-Item -Path ./js/* -Destination ./build -Recurse -Force | Out-Null

if ((Get-Command "lua_modules/bin/ldoc" -ErrorAction SilentlyContinue) -eq $null) {
echo "ldoc not found; please run scripts/install.ps1"
exit 1
}
if ((Get-Command "lua_modules/bin/ldoc" -ErrorAction SilentlyContinue) -eq $null) {
echo "ldoc not found; please run scripts/install.ps1"
exit 1
}

lua_modules/bin/ldoc .
lua_modules/bin/ldoc .
} finally {
Restore-Location
Restore-Location
}
4 changes: 2 additions & 2 deletions luacs-docs/lua/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ cd "$DIR/.."
ldoc_path=./lua_modules/bin/ldoc

if [[ ! -x "$ldoc_path" ]]; then
echo "ldoc not found; please run scripts/install.sh"
exit 1
echo "ldoc not found; please run scripts/install.sh"
exit 1
fi

rm -rf ./build
Expand Down
16 changes: 8 additions & 8 deletions luacs-docs/lua/scripts/generate_docs.ps1
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Import-Module -DisableNameChecking $PSScriptRoot/../../scripts/location.psm1

try {
Change-Location $PSScriptRoot/LuaDocsGenerator
Change-Location $PSScriptRoot/LuaDocsGenerator

if ((Get-Command "dotnet" -ErrorAction SilentlyContinue) -eq $null) {
echo "dotnet not found"
exit 1
}
if ((Get-Command "dotnet" -ErrorAction SilentlyContinue) -eq $null) {
echo "dotnet not found"
exit 1
}

dotnet build -clp:"ErrorsOnly;Summary"
dotnet run --no-build
dotnet build -clp:"ErrorsOnly;Summary"
dotnet run --no-build
} finally {
Restore-Location
Restore-Location
}
Loading

0 comments on commit cb99b19

Please sign in to comment.