Skip to content

Commit

Permalink
refactor: simplify ci and make lua and luarocks setup consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
flexiondotorg committed Jan 12, 2025
1 parent 3c4c746 commit 1748c8c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 59 deletions.
61 changes: 14 additions & 47 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,72 +9,39 @@ on:

jobs:
test:
name: Test and check ️
name: Test and check ️🔎
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- lua-type: "lua"
lua-version: "5.1"
- lua-type: "lua"
lua-version: "5.2"
- lua-type: "lua"
lua-version: "5.3"
- lua-type: "lua"
lua-version: "5.4"
- lua-type: "luajit"
luajit-version: "2.0"
- lua-type: "luajit"
luajit-version: "2.1"

lua-version: [
"5.1",
"5.2",
"5.3",
"5.4",
"luajit"
]
steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
- uses: jkl1337/gh-actions-lua@v11
with:
python-version: '3.x'

- name: Create and activate virtual environment
run: |
python -m venv venv
source venv/bin/activate
echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> $GITHUB_ENV
echo "$VIRTUAL_ENV/bin" >> $GITHUB_PATH
- name: Install hererocks
run: pip install hererocks

- name: Setup Lua
run: |
mkdir -p lua_install
if [[ "${{ matrix.lua-type }}" == "lua" ]]; then
hererocks lua_install -r^ --lua=${{ matrix.lua-version }}
else
hererocks lua_install -r^ --luajit=${{ matrix.luajit-version }}
fi
echo "$PWD/lua_install/bin" >> $GITHUB_PATH
luaVersion: "${{ matrix.lua-version }}"
- uses: jkl1337/gh-actions-luarocks@v5
with:
luaRocksVersion: "3.11.1"
- name: Install dependencies
run: |
luarocks install luacheck
luarocks install busted
luarocks install luacov
- name: Run tests and checks
run: |
luacheck --no-unused-args --std max+busted smiti18n spec
busted --verbose --coverage
- name: Generate and show coverage report
run: |
luacov
{
if [[ "${{ matrix.lua-type }}" == "lua" ]]; then
echo "# Test Coverage Summary - Lua ${{ matrix.lua-version }}"
else
echo "# Test Coverage Summary - LuaJIT ${{ matrix.luajit-version }}"
fi
echo "# Test Coverage Summary - ${{ matrix.lua-version }}"
echo ""
echo "| File | Hits | Missed | Coverage |"
echo "|------|------|---------|----------|"
Expand Down
41 changes: 29 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ on:
type: "string"
required: true

env:
VERSION: ${{ github.event.inputs.tag || github.ref_name }}

jobs:
version-check:
if: github.event_name == 'push' || github.event.inputs.tag != ''
Expand All @@ -26,12 +29,10 @@ jobs:
echo "ERROR: rockspecs directory not found"
exit 1
fi
GIT_VERSION=$(echo ${{ github.ref_name }} | sed 's/^v//')
ROCKSPEC="rockspecs/smiti18n-${GIT_VERSION}-1.rockspec"
VERSION=$(echo ${{ env.VERSION }} | sed 's/^v//')
ROCKSPEC="rockspecs/smiti18n-${VERSION}-1.rockspec"
if [ ! -e "${ROCKSPEC}" ]; then
echo "ERROR: No rockspec found for version ${GIT_VERSION}"
echo "ERROR: No rockspec found for version ${VERSION}"
echo "Expected: ${ROCKSPEC}"
ls -la rockspecs/*.rockspec
exit 1
Expand All @@ -47,13 +48,29 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "VERSION=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
else
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
fi
VERSION=$(echo ${{ env.VERSION }} | sed 's/^v//')
gh release create "${VERSION}" \
--draft=false \
--title "Release ${VERSION}" \
--generate-notes \
"rockspecs/smiti18n-${VERSION}-1.rockspec"
--generate-notes
publish-rockspec:
needs: [publish-release]
name: "Publish Rockspec 🪨"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: "Setup Lua"
uses: jkl1337/gh-actions-lua@v11
with:
luaVersion: "5.4"
- name: "Setup LuaRocks"
uses: jkl1337/gh-actions-luarocks@v5
with:
luaRocksVersion: "3.11.1"
- name: "Upload rockspec"
env:
LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }}
run: |
VERSION=$(echo ${{ env.VERSION }} | sed 's/^v//')
luarocks upload "rockspecs/smiti18n-${VERSION}-1.rockspec" --api-key=${LUAROCKS_API_KEY}

0 comments on commit 1748c8c

Please # to comment.