Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
111 changes: 69 additions & 42 deletions .github/workflows/build-extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ on:
required: true
cxx:
type: string
cache-key:
type: string
required: false
cache-dir:
type: string
required: false
sourcemod-branch:
type: string
required: false
upload:
type: boolean
required: false
Expand All @@ -22,81 +31,99 @@ on:
type: boolean
required: false
default: false
cache-key:
type: string
required: true
cache-dir:
Comment on lines -25 to -28

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the cache being removed ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion the cache didn't really add much. A shallow checkout is already quite fast and with build-containers, AMBuild is now preinstalled, so one less checkout on Linux.

One pinned revision couldn't have built 1.12 and 1.13 at once anyway. If desired, I can pin the SourceMod checkout to a fixed commit (that doesn't need the cache back), but I fear it will drift too far again like the 2023 one did. After all, isn't it (part of) the CI's purpose to report breakage due to dependency updates?

That said, this is probably the most opinionated change and I can restore the cache if needed.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI's purpose to report breakage due to dependency updates

That is true if we did build against dev SM, but since we were not. Cache here did make sense.
For the newly introduced 1.13 builds by the PR, you can omit the cache. But I would like to retain the cache for stable SM.

container:
type: string
required: true
required: false

jobs:
build:
name: Accelerator Extension ${{ inputs.os }}-${{ inputs.cc }}
name: ${{ inputs.os }}-${{ inputs.cc }}
runs-on: ${{ inputs.os }}
container: ${{ inputs.container }}

env:
SOURCEMOD: ${{ github.workspace }}/${{ inputs.cache-dir }}/sourcemod
CACHE_KEY: ${{ inputs.cache-key }}
CACHE_DIR: ${{ inputs.cache-dir }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
with:
fetch-depth: 0
submodules: true
submodules: recursive

- name: Retrieve the cache
id: cache
uses: actions/cache@v4
with:
path: ${{ inputs.cache-dir }}
key: ${{ inputs.cache-key }}
fail-on-cache-miss: true
enableCrossOsArchive: true

- name: Linux dependencies
if: startsWith(runner.os, 'Linux')
shell: bash
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
gcc-multilib g++-multilib libstdc++6 lib32stdc++6 \
libc6-dev libc6-dev-i386 linux-libc-dev \
linux-libc-dev:i386 lib32z1-dev \
zlib1g-dev:i386 zlib1g-dev ${{ inputs.cc }}
dpkg --add-architecture i386
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends --allow-downgrades \
linux-libc-dev/bullseye linux-libc-dev:i386/bullseye zstd

- name: Select clang compiler
- name: Select compiler
if: startsWith(runner.os, 'Linux')
shell: bash
run: |
echo "CC=${{ inputs.cc }}" >> $GITHUB_ENV
echo "CXX=${{ inputs.cxx }}" >> $GITHUB_ENV
${{ inputs.cc }} --version
${{ inputs.cxx }} --version

- uses: actions/setup-python@v5
name: Setup Python 3.10
- name: Retrieve the cache
if: ${{ inputs.cache-key != '' }}
uses: actions/cache/restore@v6
with:
python-version: '3.10'
path: ${{ inputs.cache-dir }}
key: ${{ inputs.cache-key }}
fail-on-cache-miss: true
enableCrossOsArchive: true

- name: Install AMBuild
- name: SourceMod checkout
if: ${{ inputs.cache-key == '' && inputs.sourcemod-branch != '' }}
uses: actions/checkout@v7
with:
repository: alliedmodders/sourcemod
ref: ${{ inputs.sourcemod-branch }}
submodules: recursive
path: sourcemod
fetch-depth: 1

- name: Resolve SourceMod path
shell: bash
run: |
python -m pip install --upgrade pip setuptools wheel
pip install ./${{ inputs.cache-dir }}/ambuild
if [ -n "$CACHE_KEY" ]; then
SOURCEMOD="$GITHUB_WORKSPACE/$CACHE_DIR/sourcemod"
else
SOURCEMOD="$GITHUB_WORKSPACE/sourcemod"
fi
if [ ! -d "$SOURCEMOD" ]; then
echo "::error::SourceMod not found at $SOURCEMOD, pass either cache-key/cache-dir or sourcemod-branch"
exit 1
fi
echo "SOURCEMOD=$SOURCEMOD" >> $GITHUB_ENV

- name: Build (Debug)
if: ${{ inputs.debug }}
- name: Install AMBuild
if: ${{ inputs.cache-key != '' || inputs.container == '' }}
shell: bash
run: |
mkdir -p build && cd build
python ../configure.py --enable-debug
ambuild
if [ -z "${{ inputs.container }}" ]; then
python3 -m pip install --upgrade pip setuptools wheel
fi
if [ -n "$CACHE_KEY" ]; then
python3 -m pip install --force-reinstall --no-deps "./$CACHE_DIR/ambuild"
else
python3 -m pip install git+https://github.com/alliedmodders/ambuild
fi

- name: Build (Release)
if: not ${{ inputs.debug }}
- name: Build
shell: bash
run: |
mkdir -p build && cd build
python ../configure.py --enable-optimize
python3 ../configure.py ${{ inputs.debug && '--enable-debug' || '--enable-optimize' }}
ambuild

- name: Upload package
if: ${{ inputs.upload }}
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: ${{ inputs.upload-artifact-name }}
path: build/package
path: build/package
30 changes: 12 additions & 18 deletions .github/workflows/cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,42 @@ on:
jobs:
cache:
name: Create cache
runs-on: 'ubuntu-latest'
runs-on: ubuntu-latest
outputs:
key: ${{ steps.cache-key.outputs.key }}

env:
SOURCEMOD_REF: 'e0e018c5ebcd11df9bab91b43d40bf148805c684'
AMBUILD_REF: '2d4620da4cdaf89cf25afc3577f920e6138ae7cd'
SOURCEMOD_REF: '2e229b111534b1be007dc3bd9acfcf2fc472e893'
AMBUILD_REF: '9ed1920068c8a767ae78022102abc93a6822eaad'
steps:
- uses: actions/checkout@v4

- name: Create cache key
run: |
echo "${{ env.SOURCEMOD_REF }}" >> cache-key
echo "${{ env.AMBUILD_REF }}" >> cache-key

- name: Output cache key
id: cache-key
run: |
ls -a
echo "key=cache-${{ hashFiles('cache-key') }}" >> $GITHUB_OUTPUT
run: echo "key=sourcemod-${SOURCEMOD_REF}-ambuild-${AMBUILD_REF}" >> $GITHUB_OUTPUT

- name: Retrieve the cache
id: cache
uses: actions/cache@v4
uses: actions/cache@v6
with:
path: .cache
key: ${{ steps.cache-key.outputs.key }}
enableCrossOsArchive: true
lookup-only: true

- uses: actions/checkout@v4
- uses: actions/checkout@v7
if: ${{ !steps.cache.outputs.cache-hit }}
name: SourceMod checkout
with:
repository: alliedmodders/sourcemod
ref: ${{ env.SOURCEMOD_REF }}
submodules: true
submodules: recursive
path: .cache/sourcemod
persist-credentials: false

- uses: actions/checkout@v4
- uses: actions/checkout@v7
if: ${{ !steps.cache.outputs.cache-hit }}
name: AMBuild checkout
with:
repository: alliedmodders/ambuild
ref: ${{ env.AMBUILD_REF }}
path: .cache/ambuild
path: .cache/ambuild
persist-credentials: false
78 changes: 47 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,61 @@ name: CI
on:
workflow_dispatch:
workflow_call:
inputs:
release:
type: boolean
required: true
default: false

jobs:
cache:
uses: ./.github/workflows/cache.yml

build-options:
runs-on: ubuntu-latest
outputs:
exclude: ${{ steps.set.outputs.exclude }}
steps:
- id: set
run: |
echo "exclude=[${{ inputs.release && '{"runners": { "upload": false } }' || '' }}]" >> $GITHUB_OUTPUT

build:
name: Build
needs: [ cache, build-options ]

sm112:
name: SM 1.12
needs: [ cache ]
strategy:
fail-fast: false
matrix:
runners: [
{ os: ubuntu-22.04, cc: clang, cxx: clang++, upload: true, upload-artifact-name: accelerator_linux },
{ os: ubuntu-latest, cc: clang, cxx: clang++, upload: false },
{ os: windows-latest, cc: msvc, cxx: msvc, upload: true, upload-artifact-name: accelerator_windows }
]
exclude: ${{ fromJson(needs.build-options.outputs.exclude) }}

include:
- os: ubuntu-latest
cc: clang-22
cxx: clang++-22
container: 'ghcr.io/alliedmodders/build-containers/debian11-clang22:latest'
artifact: accelerator_linux
- os: windows-latest
cc: msvc
cxx: msvc
container: ''
artifact: accelerator_windows
uses: ./.github/workflows/build-extension.yml
with:
os: ${{ matrix.runners.os }}
cc: ${{ matrix.runners.cc }}
cxx: ${{ matrix.runners.cxx }}
upload: ${{ matrix.runners.upload }}
upload-artifact-name: ${{ matrix.runners.upload-artifact-name }}
os: ${{ matrix.os }}
cc: ${{ matrix.cc }}
cxx: ${{ matrix.cxx }}
container: ${{ matrix.container }}
cache-key: ${{ needs.cache.outputs.key }}
cache-dir: ${{ needs.cache.outputs.dir }}
cache-dir: ${{ needs.cache.outputs.dir }}
upload: true
upload-artifact-name: ${{ matrix.artifact }}

sm113:
name: SM 1.13
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
cc: clang-22
cxx: clang++-22
container: 'ghcr.io/alliedmodders/build-containers/debian11-clang22:latest'
artifact: accelerator_sm113_linux
- os: windows-latest
cc: msvc
cxx: msvc
container: ''
artifact: accelerator_sm113_windows
uses: ./.github/workflows/build-extension.yml
with:
os: ${{ matrix.os }}
cc: ${{ matrix.cc }}
cxx: ${{ matrix.cxx }}
container: ${{ matrix.container }}
sourcemod-branch: 'master'
upload: true
upload-artifact-name: ${{ matrix.artifact }}
2 changes: 0 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@ on:
jobs:
main-ci:
uses: ./.github/workflows/ci.yml
with:
release: false
Comment thread
Kenzzer marked this conversation as resolved.
33 changes: 23 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,31 @@ on:
jobs:
main-ci:
uses: ./.github/workflows/ci.yml
with:
release: true
Comment thread
Kenzzer marked this conversation as resolved.

release:
permissions: write-all
permissions:
contents: read
runs-on: ubuntu-latest
needs: [ main-ci ]

env:
PROJECT: 'accelerator'
UPLOAD_PASSWORD: ${{ secrets.UPLOAD_PASSWORD }}
steps:
- run: sudo apt-get install -y tree

- uses: actions/checkout@v4
- uses: actions/checkout@v7
name: Repository checkout
with:
fetch-depth: 0
path: repository

- name: Download Linux release
uses: actions/download-artifact@v5
uses: actions/download-artifact@v8
with:
name: accelerator_linux
path: linux

- name: Download Windows release
uses: actions/download-artifact@v5
uses: actions/download-artifact@v8
with:
name: accelerator_windows
path: windows
Expand All @@ -55,10 +53,11 @@ jobs:
echo "LINUX_ZIP=${LINUX_ZIP}" >> $GITHUB_ENV

- name: Upload release
if: env.UPLOAD_PASSWORD != ''
Comment thread
Kenzzer marked this conversation as resolved.
shell: bash
run: |
echo "Begin upload for branch (${{ github.ref_name }})"
AUTHORIZATION="$(echo -n 'builds:${{ secrets.UPLOAD_PASSWORD }}' | base64)"
AUTHORIZATION="$(echo -n "builds:${UPLOAD_PASSWORD}" | base64)"
Comment thread
Kenzzer marked this conversation as resolved.
echo "::add-mask::${AUTHORIZATION}"

echo "Uploading ${{ env.WINDOWS_ZIP }}"
Expand All @@ -74,3 +73,17 @@ jobs:
exit 1
fi
echo "Upload successful!"

- name: Upload Windows artifact
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v7
with:
path: ${{ env.WINDOWS_ZIP }}
archive: false

- name: Upload Linux artifact
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v7
with:
path: ${{ env.LINUX_ZIP }}
archive: false
Loading