Skip to content

Commit ce33fa7

Browse files
authored
GH_action/public_repo_tests_migration_b2 (deriv-com#27)
* test gh action workflows * remove sudo chown * test caching * specify ubuntu version * try official setup-python caching * remove env * re-trigger to test caching [ci] * run without caching * test cache-hit * test cache * try again actions/cache * trigger tests * trigger test * re-trigger to test caching [ci] * use back caching by actions/setup-python@v4 * remove unwanted config * test whole workflow * specify ubuntu version * test GH workflows * fix indentation * test without git push * test without git commit and push * check branch * test schema flow * test schema flow * trigger tests * Update checkout version * add workflow dispatch * set secrets as env * trigger tests [ci] 2023-09-20 08:42:35
1 parent 90cccd7 commit ce33fa7

File tree

4 files changed

+179
-18
lines changed

4 files changed

+179
-18
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: SSH agent setup
2+
description: "Sets up ssh agent, add read ssh key and write ssh key"
3+
inputs:
4+
read_github_ssh_key:
5+
description: "ssh key to read other repos"
6+
required: false
7+
write_github_ssh_key:
8+
description: "ssh key to write other repos"
9+
required: false
10+
runs:
11+
using: composite
12+
steps:
13+
- name: set env
14+
shell: bash -e {0}
15+
working-directory: /tmp
16+
run: |
17+
eval $(ssh-agent)
18+
echo SSH_AUTH_SOCK=$SSH_AUTH_SOCK | sudo tee -a $GITHUB_ENV
19+
echo SSH_AGENT_PID=$SSH_AGENT_PID | sudo tee -a $GITHUB_ENV
20+
- name: create .ssh directory
21+
shell: bash -e {0}
22+
working-directory: /tmp
23+
run: |
24+
mkdir ~/.ssh
25+
chmod 700 ~/.ssh
26+
- name: setup read ssh key file
27+
shell: bash -e {0}
28+
working-directory: /tmp
29+
if: inputs.read_github_ssh_key != ''
30+
run: |
31+
echo "${{ inputs.read_github_ssh_key }}" >> ~/.ssh/github.com.rsa
32+
chmod 600 ~/.ssh/github.com.rsa
33+
ssh-add ~/.ssh/github.com.rsa
34+
35+
cat << EOF >> ~/.ssh/config
36+
Host github.com
37+
HostName github.com
38+
IdentitiesOnly yes
39+
IdentityFile HOME/.ssh/github.com.rsa
40+
EOF
41+
sed -i "s@HOME@$HOME/@" ~/.ssh/config
42+
chmod 600 ~/.ssh/config
43+
- name: setup write ssh key file
44+
shell: bash -e {0}
45+
working-directory: /tmp
46+
if: inputs.write_github_ssh_key != ''
47+
run: |
48+
echo "${{ inputs.write_github_ssh_key }}" >> ~/.ssh/write.github.com.rsa
49+
chmod 600 ~/.ssh/write.github.com.rsa
50+
ssh-add ~/.ssh/write.github.com.rsa
51+
52+
cat << EOF >> ~/.ssh/config
53+
Host push.github.com
54+
HostName github.com
55+
IdentitiesOnly yes
56+
IdentityFile HOME/.ssh/write.github.com.rsa
57+
EOF
58+
sed -i "s@HOME@$HOME/@" ~/.ssh/config
59+
chmod 600 ~/.ssh/config

.github/workflows/build.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Build
2+
run-name: Build
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- master
8+
pull_request:
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
jobs:
13+
test:
14+
runs-on: ubuntu-20.04
15+
strategy:
16+
matrix:
17+
python-version:
18+
- 3.9.6
19+
- 3.9.8
20+
- 3.9.9
21+
- 3.9.10
22+
- 3.9.11
23+
- 3.9.12
24+
- 3.9.13
25+
- 3.9.16
26+
- 3.10.0
27+
- 3.10.1
28+
- 3.10.2
29+
- 3.10.3
30+
- 3.10.4
31+
- 3.10.10
32+
steps:
33+
- uses: actions/checkout@v4
34+
- uses: actions/setup-python@v4
35+
with:
36+
python-version: ${{ matrix.python-version }}
37+
cache: 'pipenv'
38+
- run: make setup
39+
- run: make test
40+
- run: make coverage
41+
release:
42+
if: github.ref == 'refs/heads/master'
43+
needs: test
44+
runs-on: ubuntu-20.04
45+
env:
46+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
47+
steps:
48+
- uses: actions/checkout@v4
49+
- uses: actions/setup-python@v4
50+
with:
51+
python-version: "3.9.6"
52+
- name: setup pypi
53+
run: |
54+
echo "[pypi]" >> ~/.pypirc
55+
echo "username=__token__" >> ~/.pypirc
56+
echo "password=$PYPI_TOKEN" >> ~/.pypirc
57+
- name: release
58+
run: |
59+
python3 -m pip install --upgrade twine
60+
make build
61+
python3 -m twine upload --repository pypi dist/*
62+
echo "deployed to pypi"
63+
docs-build-deploy:
64+
if: github.ref == 'refs/heads/master'
65+
needs: release
66+
runs-on: ubuntu-20.04
67+
steps:
68+
- uses: actions/checkout@v4
69+
- uses: ./.github/actions/ssh-agent
70+
with:
71+
write_github_ssh_key: ${{ secrets.WRITE_GITHUB_SSH_KEY }}
72+
- uses: actions/setup-python@v4
73+
with:
74+
python-version: "3.9.6"
75+
cache: 'pipenv'
76+
- run: make setup
77+
- run: |
78+
git config --local user.email "sysadmin@binary.com"
79+
git config --local user.name "gh-pages deploy bot"
80+
make gh-pages

.github/workflows/build_workflow.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Update schema flow
2+
run-name: Update schema flow
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 * * *'
7+
jobs:
8+
update_schema:
9+
runs-on: ubuntu-20.04
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: ./.github/actions/ssh-agent
13+
with:
14+
write_github_ssh_key: ${{ secrets.WRITE_GITHUB_SSH_KEY }}
15+
- uses: actions/setup-python@v4
16+
with:
17+
python-version: "3.9.6"
18+
- name: config git
19+
run: |
20+
git config --global user.email "nobody@deriv.com"
21+
git config --global user.name "Nobody"
22+
- name: update schema
23+
run: |
24+
git clone https://github.com/binary-com/deriv-developers-portal.git /tmp/deriv-developers-portal
25+
curl -L https://cpanmin.us | perl - --sudo App::cpanminus
26+
sudo cpanm -n Dir::Self File::Basename JSON::MaybeXS Log::Any Path::Tiny Template Syntax::Keyword::Try
27+
BINARYCOM_API_SCHEMA_PATH=/tmp/deriv-developers-portal/config/v3 perl scripts/regen-py.pl
28+
if [[ $(git diff --shortstat) == ' 2 files changed, 2 insertions(+), 2 deletions(-)' ]]
29+
then
30+
echo 'Schema no change'
31+
exit 0
32+
fi
33+
echo "Schama updated"
34+
pip3 install bump
35+
NEXT_VER=$(bump)
36+
sed -i '/# Changelog/{s/$/\n\n## NEXTVER\n\nSync API/}' CHANGELOG.md
37+
sed -i "s/NEXTVER/$NEXT_VER/g" CHANGELOG.md
38+
git add .
39+
git commit -m 'update schema automatically'
40+
git push origin HEAD:master

0 commit comments

Comments
 (0)