Skip to content

Commit fe840ec

Browse files
committed
add github actions
1 parent 84b2d48 commit fe840ec

File tree

1 file changed

+201
-0
lines changed

1 file changed

+201
-0
lines changed

.github/workflows/shells-ci.yaml

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- "README.md"
7+
- "docs/readme.md"
8+
- "docs/readme.rst"
9+
pull_request:
10+
paths-ignore:
11+
- "README.md"
12+
- "docs/readme.md"
13+
- "docs/readme.rst"
14+
release:
15+
types: [published]
16+
17+
jobs:
18+
pre-commit:
19+
name: Run pre-commit
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v2
24+
- name: Set up Python 3.7
25+
uses: actions/setup-python@v2
26+
with:
27+
python-version: 3.7
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install pip -U
31+
pip install tox
32+
- name: Run pre-commit
33+
env:
34+
TOXENV: pre-commit
35+
run: tox
36+
pack:
37+
name: Pack the Shell
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Checkout code
41+
uses: actions/checkout@v2
42+
- name: Set up Python 3.7
43+
uses: actions/setup-python@v2
44+
with:
45+
python-version: 3.7
46+
- name: Install dependencies
47+
run: |
48+
python -m pip install pip -U
49+
pip install tox
50+
- name: Build
51+
env:
52+
TOXENV: pack
53+
run: tox
54+
download-linux-dependencies:
55+
name: Download Linux dependencies
56+
runs-on: ubuntu-latest
57+
strategy:
58+
matrix:
59+
python-version: ["2.7"]
60+
steps:
61+
- name: Checkout code
62+
uses: actions/checkout@v2
63+
- name: Set up Python ${{ matrix.python-version }}
64+
uses: actions/setup-python@v2
65+
with:
66+
python-version: ${{ matrix.python-version }}
67+
- name: Download dependencies
68+
run: |
69+
python -m pip install pip -U
70+
pip download -r src/requirements.txt -d dependencies
71+
- name: Upload artifacts
72+
uses: actions/upload-artifact@v2
73+
with:
74+
name: linux-dependencies
75+
path: |
76+
dependencies
77+
download-windows-dependencies:
78+
name: Download Windows dependencies
79+
runs-on: windows-2019
80+
strategy:
81+
matrix:
82+
python-version: ["2.7"]
83+
steps:
84+
- name: Checkout code
85+
uses: actions/checkout@v2
86+
- name: Set up Python ${{ matrix.python-version }}
87+
uses: actions/setup-python@v2
88+
with:
89+
python-version: ${{ matrix.python-version }}
90+
architecture: "x86"
91+
- name: Download dependencies
92+
run: |
93+
python -m pip install pip -U
94+
pip download -r src/requirements.txt -d dependencies
95+
- name: Upload artifacts
96+
uses: actions/upload-artifact@v2
97+
with:
98+
name: windows-dependencies
99+
path: |
100+
dependencies
101+
check-version:
102+
name: Check version
103+
# only for PRs in master
104+
if: ${{ github.base_ref == 'master' }}
105+
runs-on: ubuntu-latest
106+
steps:
107+
- name: Checkout code
108+
uses: actions/checkout@v2
109+
- name: Get current version
110+
id: currentVersion
111+
uses: mikefarah/yq@master
112+
with:
113+
cmd: yq e ".metadata.template_version" shell-definition.yaml
114+
- name: Save shell-definition.yaml from master
115+
run: |
116+
git clone https://github.com/${{ github.repository }}.git ${{ github.repository }}
117+
BASE_DIR=`pwd`
118+
cd ${{ github.repository }}
119+
git checkout -qf ${{ github.head_ref }}
120+
git show master:shell-definition.yaml > $BASE_DIR/tmp.yaml
121+
- name: Get master version
122+
id: masterVersion
123+
uses: mikefarah/yq@master
124+
with:
125+
cmd: yq e ".metadata.template_version" tmp.yaml
126+
- name: Check version
127+
run: |
128+
! diff <(echo "${{ steps.currentVersion.outputs.result }}") <(echo "${{ steps.masterVersion.outputs.result }}")
129+
check-not-shell-in-shell-name:
130+
name: Check "Shell" is not in the Shell name
131+
runs-on: ubuntu-latest
132+
steps:
133+
- name: Checkout code
134+
uses: actions/checkout@v2
135+
- name: get Node Type
136+
id: getNodeType
137+
uses: mikefarah/yq@master
138+
with:
139+
cmd: yq e ".node_types | keys | .[0]" shell-definition.yaml
140+
- name: Check shell is not in the Shell name
141+
run: |
142+
NODE_TYPE="${{ steps.getNodeType.outputs.result }}"
143+
SHELL_NAME=`echo ${NODE_TYPE:16} | tr "[:upper:]" "[:lower:]"`
144+
if [[ $SHELL_NAME == *" shell "* ]]
145+
then
146+
echo "You should remove 'Shell' from the Shell name"
147+
exit 1
148+
else
149+
echo "not found"
150+
fi
151+
create-gh-release:
152+
needs: [pre-commit, pack, download-linux-dependencies, download-windows-dependencies]
153+
if: ${{ github.ref == 'refs/heads/master' && github.event_name == 'push' }}
154+
runs-on: ubuntu-latest
155+
steps:
156+
- name: Checkout code
157+
uses: actions/checkout@v2
158+
- name: Set up Python 3.7
159+
uses: actions/setup-python@v2
160+
with:
161+
python-version: 3.7
162+
- name: Install dependencies
163+
run: |
164+
sudo apt-get -y install jq
165+
python -m pip install pip -U
166+
pip install tox yq
167+
- name: Pack
168+
env:
169+
TOXENV: pack
170+
run: tox
171+
- name: Get Linux dependencies
172+
uses: actions/download-artifact@v2
173+
with:
174+
name: linux-dependencies
175+
path: linux-dependencies
176+
- name: Get Windows dependencies
177+
uses: actions/download-artifact@v2
178+
with:
179+
name: windows-dependencies
180+
path: windows-dependencies
181+
- name: Set envs
182+
run: |
183+
version="$(yq -r .metadata.template_version shell-definition.yaml)"
184+
repo_owner=${{ github.repository }}
185+
index=`expr index "$repo_owner" /`
186+
repo=${repo_owner:index}
187+
echo "TAG=$version" >> $GITHUB_ENV
188+
echo "REPO=$repo" >> $GITHUB_ENV
189+
- name: Pack dependencies
190+
run: |
191+
zip -j dist/cloudshell-$REPO-dependencies-win-package-$TAG.zip windows-dependencies/*
192+
zip -j dist/cloudshell-$REPO-dependencies-linux-package-$TAG.zip linux-dependencies/*
193+
- name: Create GitHub release
194+
uses: ncipollo/release-action@v1
195+
with:
196+
token: ${{ secrets.GITHUB_TOKEN }}
197+
artifacts: "dist/*"
198+
draft: true
199+
name: ${{ env.REPO }} ${{ env.TAG }}
200+
tag: ${{ env.TAG }}
201+
commit: master

0 commit comments

Comments
 (0)