Skip to content

Commit

Permalink
Add GitHub workflows.
Browse files Browse the repository at this point in the history
Signed-off-by: Slava Zanko <[email protected]>
  • Loading branch information
slavaz committed Feb 14, 2024
1 parent a99de62 commit 114c889
Show file tree
Hide file tree
Showing 7 changed files with 227 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/busted.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Busted

on: [ push, pull_request ]

jobs:

busted:
strategy:
fail-fast: false
matrix:
luaVersion: [ "5.4", "5.3", "5.2" ] # , "luajit-openresty"
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup ‘lua’
uses: leafo/gh-actions-lua@v9
with:
luaVersion: ${{ matrix.luaVersion }}

- name: Setup ‘luarocks’
uses: leafo/gh-actions-luarocks@v4

- name: Setup dependencies
run: |
luarocks install --deps-only luabehave-scm-1.rockspec
luarocks install busted
luarocks install lanes # required for parallel execution
luarocks install luautf8 # required for decoder unit test
luarocks install luasocket # required for profiler unit test
luarocks install luacov-coveralls
- name: Run regression tests
run: busted -c -v

- name: Report test coverage
if: success()
continue-on-error: true
run: luacov-coveralls -i src/luacheck -e .luarocks
env:
COVERALLS_REPO_TOKEN: ${{ github.token }}
48 changes: 48 additions & 0 deletions .github/workflows/deploy-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#
name: Build and publish Docker image

# This workflow runs when any of the following occur:
# - A push is made to a branch called `main`
# - A tag starting with "v" is created
on:
push:
branches:
- main
tags:
- v*
env:
IMAGE_NAME: luabehave
#
jobs:
# This pushes the image to GitHub Packages.
push:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
#
steps:
- uses: actions/checkout@v4

- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"

- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
#
- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
# This changes all uppercase characters to lowercase.
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# This strips the git ref prefix from the version.
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# This strips the "v" prefix from the tag name.
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# This uses the Docker `latest` tag convention.
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
39 changes: 39 additions & 0 deletions .github/workflows/luabehave.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: LuaBehave

on: [ push, pull_request ]

jobs:

luabehave:
strategy:
fail-fast: false
matrix:
luaVersion: [ "5.4", "5.3", "5.2" ]
penlightVersion: [ "1.13.1", "1.9.2", "1.8.0", "1.6.0", "1.3.2" ]
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup ‘lua’
uses: leafo/gh-actions-lua@v9
with:
luaVersion: ${{ matrix.luaVersion }}

- name: Setup ‘luarocks’
uses: leafo/gh-actions-luarocks@v4

- name: Setup dependencies
run: |
luarocks install penlight ${{ matrix.penlightVersion }}
luarocks install luassert
luarocks install argparse
luarocks install --deps-only luabehave-scm-1.rockspec
- name: Build ‘luabehave’ (bootstrap)
run: |
luarocks make
- name: Run ‘luabehave’ (dogfood)
# disable project-local path prefixes to force use of system installation
run: luabehave
13 changes: 13 additions & 0 deletions .github/workflows/luacheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Luacheck

on: [push, pull_request]

jobs:

luacheck:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Luacheck
uses: lunarmodules/luacheck@v0
38 changes: 38 additions & 0 deletions .github/workflows/luarocks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
name: Publish package on LuaRocks

# This workflow runs when any of the following occur:
# - A push is made to a branch called `main`
# - A tag starting with "v" is created
on:
push:
branches:
- main
tags:
- v*
env:
IMAGE_NAME: luabehave
#
jobs:
upload:
name: Build rocks and upload to LuaRocks
runs-on: ubuntu-22.04
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup ‘lua’
uses: leafo/gh-actions-lua@v10
- name: Setup ‘luarocks’
uses: leafo/gh-actions-luarocks@v4
- name: Setup dependencies
run: |
luarocks install dkjson
- name: Upload dev rockspec to luarocks
# Upload dev rockspecs any time they are touched
run: |
args="--temp-key ${{ secrets.LUAROCKS_APIKEY }} --force"
luarocks upload $args -- luabehave-scm-1.rockspec
16 changes: 16 additions & 0 deletions .github/workflows/versioning.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Versioning

on:
release:
types: [ created, published, edited ]

jobs:
actions-tagger:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Update release tags
uses: Actions-R-Us/actions-tagger@v2
with:
publish_latest_tag: true
31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#syntax=docker/dockerfile:1.2

FROM akorn/luarocks:lua5.4-alpine AS builder

RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing \
dumb-init gcc libc-dev

COPY ./ /src
WORKDIR /src

RUN luarocks --tree /pkgdir/usr/local make
RUN find /pkgdir -type f -exec sed -i -e 's!/pkgdir!!g' {} \;

FROM akorn/luarocks:lua5.4-alpine AS final

RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing \
dumb-init

LABEL org.opencontainers.image.title="LuaBehave"
LABEL org.opencontainers.image.description="BDD (Behavior-Driven Development) testing framework"
LABEL org.opencontainers.image.authors="Slava Zanko <[email protected]>"
LABEL org.opencontainers.image.licenses="MIT"
LABEL org.opencontainers.image.url="https://github.com/slavaz/luabehave/pkgs/container/luabehave"
LABEL org.opencontainers.image.source="https://github.com/slavaz/luabehave"

COPY --from=builder /pkgdir /
RUN luabehave --help

WORKDIR /data

ENTRYPOINT ["luabehave"]

0 comments on commit 114c889

Please sign in to comment.