Skip to content

Commit

Permalink
Introduces github workflows (#3)
Browse files Browse the repository at this point in the history
* gh: adds linter workflows

* gh: fixes linter config

* lint: removes unused code

* gh: adds autorelease and publish rockspec

* gh: adds tests workflow

* gh: maybe fix

* gh: fixes missprint

* gh: adds dependencies on tests and linting

---------

Co-authored-by: Vladislav Grubov <[email protected]>
  • Loading branch information
ochaton and Vladislav Grubov authored Mar 15, 2023
1 parent 0ff2de6 commit 23e32be
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 11 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Linting with luacheck

on:
- push
- pull_request

jobs:
run-luacheck-linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: tarantool/setup-tarantool@v2
with:
tarantool-version: '2.10.4'

- name: install tarantool/luacheck and execute it
run: tarantoolctl rocks install luacheck && .rocks/bin/luacheck .
58 changes: 58 additions & 0 deletions .github/workflows/push-rockspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Create and push rockspec for moonlibs/sync

on:
workflow_dispatch:
workflows:
- "Linting with luacheck"
- "Testing with unit tests"
types:
- completed
push:
tags:
- '*'

env:
ROCK_NAME: sync

jobs:
pack-and-push-tagged-rockspec:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }} && startsWith(github.ref, 'refs/tags/') }}
steps:
- uses: actions/checkout@v3
- uses: tarantool/setup-tarantool@v2
with:
tarantool-version: '2.10.4'

# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
- name: Set env
run: echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- run: tarantoolctl rocks new_version --tag=${{ env.TAG }} rockspecs/sync-scm-1.rockspec ${{ env.TAG }} "git+https://github.com/${{ github.repository }}.git"
- run: tarantoolctl rocks install ${{ env.ROCK_NAME }}-${{ env.TAG }}-1.rockspec
- run: tarantoolctl rocks pack ${{ env.ROCK_NAME }}-${{ env.TAG }}-1.rockspec
# Install native lua with luarocks
- uses: leafo/gh-actions-lua@v9
with:
luaVersion: "luajit-2.1.0-beta3"
- uses: leafo/gh-actions-luarocks@v4
with:
luarocksVersion: "3.8.0"
- uses: unfor19/[email protected]
- run: mkdir .build && cp rockspecs/${{env.ROCK_NAME}}-scm-1.rockspec ${{env.ROCK_NAME}}-${{env.TAG}}-1.rockspec .build/ && cp *.src.rock .build/
- name: rebuild and publish s3 luarocks server
env:
AWS_ACCESS_KEY_ID: ${{ secrets.MOONLIBS_S3_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.MOONLIBS_S3_SECRET_KEY}}
AWS_EC2_METADATA_DISABLED: true
run: |
cd .build && aws s3 sync s3://moonlibs/ ./ && luarocks-admin make_manifest . && aws s3 sync --acl public-read ./ s3://moonlibs/;
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
README.md
${{env.ROCK_NAME}}-scm-1.rockspec
${{env.ROCK_NAME}}-${{env.TAG}}-1.rockspec
${{env.ROCK_NAME}}-${{env.TAG}}-1.src.rock
28 changes: 28 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Testing with unit tests

on:
- push
- pull_request

jobs:
run-unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: tarantool/setup-tarantool@v2
with:
tarantool-version: '2.10.4'
- name: setup perl
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: 5.18.4
- name: show perl version
run: |
perl -v
- name: install TAP::Harness
run: |
cpanm -v
cpanm --notest TAP::Harness
- name: run tests
run: |
make test
2 changes: 2 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
std="tarantool"

include_files = {"sync/", "sync.lua"}
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.PHONY: test

test:
prove test/*.test.lua
11 changes: 0 additions & 11 deletions sync/lock.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,6 @@ function lock:_self_check()
end
end

local function find_lockers(lock, t)
t = t or {}
--[[
1. lock has only one locker fiber
2. fiber may have several locks it keeps
0. harmless, forget it.
1+. check every lock for lockers
]]

end

function lock:aquire(timeout)
if getmetatable( self ) ~= lock then
error("Usage: lock:aquire() (not lock.aquire())", 2)
Expand Down

0 comments on commit 23e32be

Please sign in to comment.