Skip to content

Commit b45bb31

Browse files
committed
Refactor GitHub Actions workflows
* Separate push-rockspec flow * Fix push-tagged-rockspec job * Run tests for PR or push, not both
1 parent aaf4106 commit b45bb31

File tree

2 files changed

+63
-36
lines changed

2 files changed

+63
-36
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Push rockspec
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
env:
9+
ROCK_NAME: "crud"
10+
11+
jobs:
12+
push-scm-rockspec:
13+
runs-on: [ ubuntu-latest ]
14+
if: github.ref == 'refs/heads/master'
15+
steps:
16+
- uses: actions/checkout@master
17+
18+
- name: Push scm rockspec
19+
run: |
20+
curl --fail -X PUT -F rockspec=@$ROCK_NAME-scm-1.rockspec \
21+
https://${{ secrets.ROCKS_USERNAME }}:${{ secrets.ROCKS_PASSWORD }}@${{ secrets.ROCKS_SERVER }}
22+
push-tagged-rockspec:
23+
runs-on: [ ubuntu-latest ]
24+
if: startsWith(github.ref, 'refs/tags')
25+
steps:
26+
- uses: actions/checkout@master
27+
28+
# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
29+
- name: Set env
30+
run: echo "GIT_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
31+
32+
- name: Push release rockspec
33+
run: |
34+
cat $ROCK_NAME-scm-1.rockspec |
35+
sed -E \
36+
-e "s/branch = '.+'/tag = '${GIT_TAG}'/g" \
37+
-e "s/version = '.+'/version = '${GIT_TAG}-1'/g" |
38+
curl --fail -X PUT -F "rockspec=@-;filename=$ROCK_NAME-${GIT_TAG}-1.rockspec" \
39+
https://${{ secrets.ROCKS_USERNAME }}:${{ secrets.ROCKS_PASSWORD }}@rocks.tarantool.org

.github/workflows/test_on_push.yaml

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,36 @@ on:
44
push:
55
pull_request:
66

7-
env:
8-
ROCK_NAME: "crud"
9-
107
jobs:
118
run-tests-ce:
9+
if: |
10+
github.event_name == 'push' ||
11+
github.event_name == 'pull_request' && github.actor != 'tarantool'
1212
strategy:
1313
matrix:
1414
tarantool-version: ["1.10", "2.3", "2.4", "2.5"]
1515
fail-fast: false
1616
runs-on: [ubuntu-latest]
1717
steps:
1818
- uses: actions/checkout@master
19-
- name: Install requirements for community
20-
run: |
21-
curl -L https://tarantool.io/installer.sh | sudo VER=${{ matrix.tarantool-version }} bash
22-
sudo apt install -y tarantool-dev
23-
./deps.sh
24-
- name: Run linter
25-
run: .rocks/bin/luacheck .
26-
- name: Run tests
27-
run: .rocks/bin/luatest -v
19+
20+
- name: Echo
21+
run: echo ${{ github.event.pull_request.head.label }}
22+
23+
- name: Echo
24+
run: echo ${{ github.event.pull_request.head.repo.owner.login }}
25+
26+
# - name: Install requirements for community
27+
# run: |
28+
# curl -L https://tarantool.io/installer.sh | sudo VER=${{ matrix.tarantool-version }} bash
29+
# sudo apt install -y tarantool-dev
30+
# ./deps.sh
31+
32+
# - name: Run linter
33+
# run: .rocks/bin/luacheck .
34+
35+
# - name: Run tests
36+
# run: .rocks/bin/luatest -v
2837

2938
run-tests-ee:
3039
if: github.event_name == 'push'
@@ -35,6 +44,7 @@ jobs:
3544
runs-on: [ ubuntu-latest ]
3645
steps:
3746
- uses: actions/checkout@master
47+
3848
- name: Install requirements for enterprise
3949
run: |
4050
curl -O -L https://tarantool:${{ secrets.DOWNLOAD_TOKEN }}@download.tarantool.io/enterprise/tarantool-enterprise-bundle-${{ matrix.bundle_version }}.tar.gz
@@ -43,31 +53,9 @@ jobs:
4353
sudo cp tarantool-enterprise/tarantool /usr/bin/tarantool
4454
source tarantool-enterprise/env.sh
4555
./deps.sh
56+
4657
- name: Run linter
4758
run: .rocks/bin/luacheck .
59+
4860
- name: Run tests
4961
run: .rocks/bin/luatest -v
50-
51-
push-rockspec:
52-
runs-on: [ ubuntu-latest ]
53-
steps:
54-
- uses: actions/checkout@master
55-
# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
56-
- name: Set env
57-
run: echo "GIT_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
58-
- name: Push scm rockspec
59-
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
60-
run: |
61-
curl --fail -X PUT -F rockspec=@$ROCK_NAME-scm-1.rockspec \
62-
https://${{ secrets.ROCKS_USERNAME }}:${{ secrets.ROCKS_PASSWORD }}@${{ secrets.ROCKS_SERVER }}
63-
- name: Push release rockspec
64-
if: startsWith(github.ref, 'refs/tags')
65-
run: |
66-
curl --fail -X PUT -F rockspec=@$ROCK_NAME-scm-1.rockspec \
67-
https://${{ secrets.ROCKS_USERNAME }}:${{ secrets.ROCKS_PASSWORD }}@${{ secrets.ROCKS_SERVER }} \
68-
cat $ROCK_NAME-scm-1.rockspec |
69-
sed -E \
70-
-e "s/branch = '.+'/tag = '${GIT_TAG}'/g" \
71-
-e "s/version = '.+'/version = '${GIT_TAG}-1'/g" |
72-
curl --fail -X PUT -F "rockspec=@-;filename=$ROCK_NAME-${GIT_TAG}-1.rockspec" \
73-
https://${{ secrets.ROCKS_USERNAME }}:${{ secrets.ROCKS_PASSWORD }}@rocks.tarantool.org

0 commit comments

Comments
 (0)