Skip to content

Python CI

Python CI #389

name: Python CI
on:
push:
pull_request:
schedule:
- cron: '0 23 * * 1,2,3,4,5'
jobs:
fetch-data:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.10.4'
architecture: 'x64'
- name: Display Python version
run: python --version
- name: Install dependencies
run: python -m pip install "pandas==1.4.2" "requests==2.27.1" "lxml==4.8.0"
- name: Fetch data
uses: nick-fields/retry@v2
with:
timeout_seconds: 120
max_attempts: 5
retry_on: error
command: python download_script.py
- uses: actions/upload-artifact@v3
with:
name: artifacts
path: build/
if-no-files-found: error
- name: Set up the SSH key and the known_hosts file
uses: shimataro/[email protected]
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
name: id_rsa
known_hosts: unnecessary
if_key_exists: fail
- name: Configure git
shell: bash
run: |
CI_WORK_DIR=`pwd`
mkdir -p ~/workdir
cd ~/workdir
git config --global user.email "[email protected]"
git config --global user.name "GithubActions CI (via TheSnoozer)"
git clone --depth 1 --branch data [email protected]:TheSnoozer/putcallratio.git
cd putcallratio
TODAY=$(date "+%Y-%m-%d")
# Merge total_options
[[ ! -e "total_options.tsv" ]] && cp "${CI_WORK_DIR}"/build/total_options.tsv .
awk 'FNR==1 && NR!=1{next;}{print}' "${CI_WORK_DIR}"/build/total_options.tsv total_options.tsv | awk '!seen[$0]++' > tmp_total_options.tsv
mv tmp_total_options.tsv total_options.tsv
# Merge index_options
[[ ! -e "index_options.tsv" ]] && cp "${CI_WORK_DIR}"/build/index_options.tsv .
awk 'FNR==1 && NR!=1{next;}{print}' "${CI_WORK_DIR}"/build/index_options.tsv index_options.tsv | awk '!seen[$0]++' > tmp_index_options.tsv
mv tmp_index_options.tsv index_options.tsv
# Merge equity_options
[[ ! -e "equity_options.tsv" ]] && cp "${CI_WORK_DIR}"/build/equity_options.tsv .
awk 'FNR==1 && NR!=1{next;}{print}' "${CI_WORK_DIR}"/build/equity_options.tsv equity_options.tsv | awk '!seen[$0]++' > tmp_equity_options.tsv
mv tmp_equity_options.tsv equity_options.tsv
# Add files and commit
[[ -n $(git status --porcelain) ]] || (echo "Nothing to commit!" && exit 0)
git add total_options.tsv index_options.tsv equity_options.tsv
git commit -m "Add data for ${TODAY}"
git push origin -o ci.skip -q