Skip to content

Commit 0851cb3

Browse files
authored
Refactor GitHub Actions workflows (#67)
* Separate push-rockspec flow * Fix push-tagged-rockspec job * Run tests for PR or push, not both
1 parent bea9a83 commit 0851cb3

File tree

2 files changed

+48
-27
lines changed

2 files changed

+48
-27
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: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,28 @@ 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.event.pull_request.head.repo.owner.login != '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+
1920
- name: Install requirements for community
2021
run: |
2122
curl -L https://tarantool.io/installer.sh | sudo VER=${{ matrix.tarantool-version }} bash
2223
sudo apt install -y tarantool-dev
2324
./deps.sh
25+
2426
- name: Run linter
2527
run: .rocks/bin/luacheck .
28+
2629
- name: Run tests
2730
run: .rocks/bin/luatest -v
2831

@@ -35,6 +38,7 @@ jobs:
3538
runs-on: [ ubuntu-latest ]
3639
steps:
3740
- uses: actions/checkout@master
41+
3842
- name: Install requirements for enterprise
3943
run: |
4044
curl -O -L https://tarantool:${{ secrets.DOWNLOAD_TOKEN }}@download.tarantool.io/enterprise/tarantool-enterprise-bundle-${{ matrix.bundle_version }}.tar.gz
@@ -43,31 +47,9 @@ jobs:
4347
sudo cp tarantool-enterprise/tarantool /usr/bin/tarantool
4448
source tarantool-enterprise/env.sh
4549
./deps.sh
50+
4651
- name: Run linter
4752
run: .rocks/bin/luacheck .
53+
4854
- name: Run tests
4955
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)