Skip to content

Commit 809763f

Browse files
committed
Refactor CI
1 parent 13e78ac commit 809763f

File tree

2 files changed

+151
-56
lines changed

2 files changed

+151
-56
lines changed

.github/workflows/CI.yaml

Lines changed: 65 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,6 @@ name: CI
33
on: [push]
44

55
jobs:
6-
release:
7-
runs-on: ubuntu-latest
8-
steps:
9-
- name: Checkout
10-
uses: actions/checkout@v2
11-
12-
- name: Test swiftbox
13-
run: |
14-
chmod +x swiftbox.sh
15-
VERSION=`./swiftbox.sh version`
16-
echo "::set-env name=version::$VERSION"
17-
if [ $? = 0 ]
18-
then
19-
if [ v$VERSION != `curl -fsSL https://api.github.com/repos/stevapple/swiftbox/releases/latest | jq .tag_name | sed "s/\"//g"` ]
20-
then
21-
echo "::set-env name=updated::true"
22-
fi
23-
else
24-
exit 1
25-
fi
26-
27-
- name: Tag and release
28-
uses: avakar/tag-and-release@v1
29-
if: ${{ env.updated }}
30-
with:
31-
release_name: Release ${{ env.version }}
32-
tag_name: v${{ env.version }}
33-
env:
34-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35-
366
test-ubuntu:
377
runs-on: ubuntu-18.04
388
needs: release
@@ -45,45 +15,48 @@ jobs:
4515
chmod +x swiftbox.sh
4616
./swiftbox.sh version
4717
18+
- name: Test swiftbox install
19+
run: swiftbox install
20+
4821
- name: Test swiftbox lookup
49-
run: ./swiftbox.sh lookup 5.1.5
22+
run: swiftbox lookup 5.1.5
5023

5124
- name: Test swiftbox get with sudo
5225
run: |
53-
sudo ./swiftbox.sh get 5.1.2
26+
sudo swiftbox get 5.1.2
5427
source /etc/environment
5528
source /etc/profile.d/swiftbox.sh
5629
which swift
5730
swiftc -v
5831
5932
- name: Test swiftbox get
6033
run: |
61-
./swiftbox.sh get 5.2
62-
./swiftbox.sh get 5.1.5
34+
swiftbox get 5.2
35+
swiftbox get 5.1.5
6336
source /etc/environment
6437
source $HOME/.swiftbox/env.sh
6538
swiftc -v
6639
6740
- name: Test swiftbox list and use
6841
run: |
69-
./swiftbox.sh list
70-
sudo ./swiftbox.sh list
71-
./swiftbox.sh use 5.1.5
72-
./swiftbox.sh list
42+
swiftbox list
43+
sudo swiftbox list
44+
swiftbox use 5.1.5
45+
swiftbox list
7346
source /etc/environment
7447
source $HOME/.swiftbox/env.sh
7548
swiftc -v
7649
7750
- name: Test swiftbox clean
7851
run: |
79-
./swiftbox.sh clean
80-
sudo ./swiftbox.sh clean
52+
swiftbox clean
53+
sudo swiftbox clean
8154
8255
- name: Test swiftbox remove
8356
run: |
84-
sudo ./swiftbox.sh remove 5.1.2
85-
./swiftbox.sh remove 5.1.5
86-
./swiftbox.sh use 5.2
57+
sudo swiftbox remove 5.1.2
58+
swiftbox remove 5.1.5
59+
swiftbox use 5.2
8760
8861
- name: Test Swift status
8962
run: |
@@ -101,7 +74,7 @@ jobs:
10174
swiftc test.swift -o test && ./test
10275
10376
- name: Test swiftbox close
104-
run: ./swiftbox.sh close
77+
run: swiftbox close
10578

10679
- name: Test Swift disabled
10780
run: |
@@ -112,13 +85,39 @@ jobs:
11285
exit 1
11386
fi
11487
115-
- name: Test swiftbox install and update
88+
test-ubuntu-nightly:
89+
container:
90+
image: ubuntu:20.04
91+
runs-on: ubuntu-latest
92+
steps:
93+
- name: Checkout
94+
uses: actions/checkout@v2
95+
96+
- name: Test swiftbox version
97+
run: |
98+
chmod +x swiftbox.sh
99+
./swiftbox.sh version
100+
101+
- name: Test swiftbox get nightly
102+
run: ./swiftbox.sh get nightly
103+
104+
- name: Test Swift status
105+
run: |
106+
source /etc/environment
107+
source $HOME/.swiftbox/env.sh
108+
echo "\$PATH=$PATH"
109+
./swiftbox.sh list
110+
which swift
111+
swiftc -v
112+
113+
- name: Test Swift compiler
116114
run: |
117-
sh -c "$(curl -fsSL https://raw.githubusercontent.com/stevapple/swiftbox/master/install.sh)"
118-
swiftbox version
119-
swiftbox update
115+
source /etc/environment
116+
source $HOME/.swiftbox/env.sh
117+
swift test.swift
118+
swiftc test.swift -o test && ./test
120119
121-
test-centos:
120+
test-centos-nightly:
122121
needs: release
123122
container:
124123
image: centos:8
@@ -131,12 +130,22 @@ jobs:
131130
run: |
132131
chmod +x swiftbox.sh
133132
./swiftbox.sh version
134-
135-
- name: Wait for CDN refreshment
136-
run: sleep 30s
137133
138-
- name: Test swiftbox install and update
134+
- name: Test swiftbox get nightly
135+
run: ./swiftbox.sh get nightly
136+
137+
- name: Test Swift status
139138
run: |
140-
sh -c "$(curl -fsSL https://raw.githubusercontent.com/stevapple/swiftbox/master/install.sh)"
141-
swiftbox version
142-
swiftbox update
139+
source /etc/environment
140+
source $HOME/.swiftbox/env.sh
141+
echo "\$PATH=$PATH"
142+
./swiftbox.sh list
143+
which swift
144+
swiftc -v
145+
146+
- name: Test Swift compiler
147+
run: |
148+
source /etc/environment
149+
source $HOME/.swiftbox/env.sh
150+
swift test.swift
151+
swiftc test.swift -o test && ./test

.github/workflows/Tag.yaml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Tag
2+
3+
on: [push]
4+
5+
jobs:
6+
release:
7+
runs-on: ubuntu-latest
8+
outputs:
9+
updated: ${{ steps.main.outputs.updated }}
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v2
13+
14+
- id: main
15+
name: Test swiftbox
16+
run: |
17+
chmod +x swiftbox.sh
18+
VERSION=`./swiftbox.sh version`
19+
echo "::set-env name=version::$VERSION"
20+
if [ $? = 0 ]
21+
then
22+
if [ v$VERSION != `curl -fsSL https://api.github.com/repos/stevapple/swiftbox/releases/latest | jq .tag_name | sed "s/\"//g"` ]
23+
then
24+
echo "::set-env name=updated::true"
25+
echo "::set-output name=updated::true"
26+
fi
27+
else
28+
exit 1
29+
fi
30+
31+
- name: Tag and release
32+
uses: avakar/tag-and-release@v1
33+
if: ${{ env.updated }}
34+
with:
35+
release_name: Release ${{ env.version }}
36+
tag_name: v${{ env.version }}
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
40+
wait-for-cdn:
41+
runs-on: ubuntu-latest
42+
needs: release
43+
if: ${{ needs.release.outputs.updated }}
44+
steps:
45+
- name: Wait for CDN refreshment
46+
run: sleep 30s
47+
48+
test-ubuntu-install:
49+
needs: wait-for-cdn
50+
container:
51+
image: ubuntu:20.04
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: Install sudo
55+
run: apt-get install sudo -y
56+
57+
- name: Test swiftbox install and update
58+
run: |
59+
sh -c "$(curl -fsSL https://raw.githubusercontent.com/stevapple/swiftbox/master/install.sh)"
60+
swiftbox version
61+
sudo swiftbox update
62+
63+
- name: Test swiftbox setup
64+
run: |
65+
swiftbox list
66+
sudo swiftbox list
67+
68+
test-centos-install:
69+
needs: wait-for-cdn
70+
container:
71+
image: centos:8
72+
runs-on: ubuntu-latest
73+
steps:
74+
- name: Install sudo
75+
run: yum install sudo -y
76+
77+
- name: Test swiftbox install and update
78+
run: |
79+
sh -c "$(curl -fsSL https://raw.githubusercontent.com/stevapple/swiftbox/master/install.sh)"
80+
swiftbox version
81+
sudo swiftbox update
82+
83+
- name: Test swiftbox setup
84+
run: |
85+
swiftbox list
86+
sudo swiftbox list

0 commit comments

Comments
 (0)