Skip to content

Commit

Permalink
ci: refactor env variable, remove unused code (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
HKuz authored and agritheory committed May 6, 2024
1 parent b3b0a2e commit e7acef9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 51 deletions.
28 changes: 4 additions & 24 deletions .github/helper/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ fi

cd ~ || exit

# sudo apt update -y && sudo apt install redis-server -y

pip install --upgrade pip
pip install frappe-bench

Expand All @@ -28,25 +26,8 @@ mysql --host 127.0.0.1 --port 3306 -u root -e "GRANT ALL PRIVILEGES ON \`test_si
mysql --host 127.0.0.1 --port 3306 -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'root'" # match site_cofig
mysql --host 127.0.0.1 --port 3306 -u root -e "FLUSH PRIVILEGES"

echo "------ CI VARIABLES ------"
echo "GITHUB_EVENT_NAME:"
echo "${GITHUB_EVENT_NAME}" # push, pull_request
echo "GITHUB_BASE_REF:" # only works when event is pull request
echo "${GITHUB_BASE_REF}" # blank for push, version-14 for pull_request
echo "GITHUB_REF_NAME (for push/tag, format for PR is pr#/merge):"
echo "${GITHUB_REF_NAME}" # version-15 for push, pr#/merge for pull_request
echo "--------------------------"

if [ "${GITHUB_EVENT_NAME}" = 'pull_request' ]; then
echo "GITHUB_EVENT_NAME IS pull_request"
BRANCH_NAME="${GITHUB_BASE_REF}"
else
echo "GITHUB_EVENT_NAME IS push"
BRANCH_NAME="${GITHUB_REF_NAME}"
fi
echo "BRANCH_NAME IS: ${BRANCH_NAME}"

git clone https://github.com/frappe/frappe --branch "${BRANCH_NAME}"
echo BRANCH_NAME: "${BRANCH_NAME}"
git clone https://github.com/frappe/frappe --branch ${BRANCH_NAME}
bench init frappe-bench --frappe-path ~/frappe --python "$(which python)" --skip-assets --ignore-exist

mkdir ~/frappe-bench/sites/test_site
Expand All @@ -59,8 +40,8 @@ sed -i 's/schedule:/# schedule:/g' Procfile
sed -i 's/socketio:/# socketio:/g' Procfile
sed -i 's/redis_socketio:/# redis_socketio:/g' Procfile

bench get-app https://github.com/frappe/erpnext --branch "${BRANCH_NAME}" --resolve-deps --skip-assets
bench get-app beam "${GITHUB_WORKSPACE}" --skip-assets --resolve-deps
bench get-app erpnext https://github.com/frappe/erpnext --branch ${BRANCH_NAME} --resolve-deps --skip-assets
bench get-app beam "${GITHUB_WORKSPACE}" --skip-assets

printf '%s\n' 'frappe' 'erpnext' 'beam' > ~/frappe-bench/sites/apps.txt
bench setup requirements --python
Expand All @@ -70,7 +51,6 @@ bench start &> bench_run_logs.txt &
CI=Yes &
bench --site test_site reinstall --yes --admin-password admin

# bench --site test_site install-app erpnext beam
bench setup requirements --dev

echo "BENCH VERSION NUMBERS:"
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/generate_matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- version-14
- version-15
pull_request:

env:
Expand All @@ -16,9 +17,9 @@ jobs:
- uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Generate Scanning Decision Matrix
run: python3 ./beam/docs/generate_matrix.py
run: python3 ./beam/docs/generate_matrix.py
29 changes: 20 additions & 9 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
- version-14
- version-15
pull_request:
branches:
- version-14
- version-15

env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -16,13 +19,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 2

- name: Setup Python
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: '3.10'

Expand All @@ -44,13 +47,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 2

- name: Setup Python
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: '3.10'

Expand All @@ -65,7 +68,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 2
Expand All @@ -81,21 +84,21 @@ jobs:
shell: bash
run: |
echo "The following files are not formatted:"
echo "${{steps.prettier-run.outputs.prettier_output}}"
echo "${{steps.prettier-run.outputs.prettier_output}}" >> $GITHUB_OUTPUT
json_diff:
needs: [ py_json_merge ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 2

- name: Find JSON changes
id: changed-json
uses: tj-actions/changed-files@v36
uses: tj-actions/changed-files@v43
with:
files: |
**/*.json
Expand Down Expand Up @@ -139,11 +142,19 @@ jobs:
echo "D,${file}" >> base/mrd.txt
done
- name: Setup requirements and script
run: |
pip install rich
pip install json_source_map
git clone --depth 1 https://gist.github.com/3eea518743067f1b971114f1a2016f69 fsjd
- name: Diff table
run: python3 fsjd/frappe_schema_json_diff.py base/mrd.txt head/acmr.txt 1

py_json_merge:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Fetch validator
run: git clone --depth 1 https://gist.github.com/f1bf2c11f78331b2417189c385022c28.git validate_json
Expand Down
19 changes: 3 additions & 16 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
branches:
- version-14
- version-15
env:
BRANCH_NAME: ${{ github.base_ref || github.ref_name }}

# concurrency:
# group: develop-cloud_storage-${{ github.event.number }}
Expand Down Expand Up @@ -48,10 +50,6 @@ jobs:
node-version: 18
check-latest: true
cache: 'yarn' # Replaces `Get yarn cache directory path` and `yarn-cache` steps

# Uncomment if running locally, remove after local testing (already available in github actions environment)
# - name: Install Yarn
# run: npm install -g yarn

- name: Add to Hosts
run: echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts
Expand All @@ -65,18 +63,6 @@ jobs:
${{ runner.os }}-pip-
${{ runner.os }}-
# - name: Get yarn cache directory path
# id: yarn-cache-dir-path
# run: 'echo "::set-output name=dir::$(yarn cache dir)"'

# - uses: actions/cache@v3
# id: yarn-cache
# with:
# path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
# key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
# restore-keys: |
# ${{ runner.os }}-yarn-

- name: Install JS Dependencies
run: yarn --prefer-offline

Expand All @@ -87,6 +73,7 @@ jobs:
env:
MYSQL_HOST: 'localhost'
MYSQL_PWD: 'admin'
BRANCH_NAME: ${{ env.BRANCH_NAME}}
run: |
bash ${{ github.workspace }}/.github/helper/install.sh
Expand Down

0 comments on commit e7acef9

Please sign in to comment.