-
Notifications
You must be signed in to change notification settings - Fork 3
62 lines (61 loc) · 2.17 KB
/
Copy pathtesting.yml
File metadata and controls
62 lines (61 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
name: python testing
on:
# target dari branch yang akan di pull request
# atau di commit langsung
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
# untuk build terdapat 3 environment os
# macOS, windows, linux
runs-on: ubuntu-latest
steps:
# menggunakan checkout untuk cek kode
- uses: actions/checkout@v2
# menggunakan environment python versi 3.9
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: "3.9"
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt')}}
# testing bash dengan perintah echo
- name: salam
run: |
echo "Halo!"
echo "Mulai testing..."
echo "harap tunggu sebentar... :)"
# install requirement yang diperlukan
# sebelum testing semua kode
# bisa dilihat requirement yang dibutuhkan
# pada file 'requirements.txt'
- name: Install dependencies
run: |
echo "Mulai jalankan install requirement"
python -m pip install --upgrade pip
pip install -r requirements.txt
# memformat kode secara otomatis dengan black
# tujuannya agar kode lebih mudah dibaca
- name: Format otomatis
run: |
echo "Mulai format otomatis"
isort .
# ketika sudah di format maka kode akan mengcommit kembali
# dan commit akan otomatis menggunakan github bot yang sudah tersedia
# disini kondisi jika file tersebut ada perubahan maka akan di format
- name: Cek modifikasi file
id: git-check
run: echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "tidak"; else echo "ya"; fi)
- name: Push perubahan
if: steps.git-check.outputs.modified == 'ya' && github.event_name == 'push'
run: |
git config --global user.name 'bellshadebot'
git config --global user.email 'bellshade07@gmail.com'
git remote set-url origin https://x-access-token:${{ secrets.PYTHONAPPS }}@github.com/${{ github.repository }}
git pull
git commit -am "style: format otomatis dengan black dan isort"
git push