Skip to content

Commit

Permalink
Compute diff
Browse files Browse the repository at this point in the history
  • Loading branch information
looi committed May 20, 2021
1 parent c66a7c4 commit fad04f4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM apache/airflow:1.10.10-python3.7

COPY entrypoint.sh /entrypoint.sh
COPY main.py /main.py
COPY dump_dags.py /dump_dags.py

ENTRYPOINT ["/entrypoint.sh"]
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: 'Diff Airflow DAG'
description: 'Gets diff of airflow DAG.'
outputs:
diff:
description: 'The diff of the DAGs.'
runs:
using: 'docker'
image: 'Dockerfile'
6 changes: 5 additions & 1 deletion main.py → dump_dags.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ def dump_dags(outfile):


if __name__ == '__main__':
dump_dags(sys.stdout)
if len(sys.argv) != 2:
print('Usage: dump_dags.py <output filename>')
sys.exit(1)
with open(sys.argv[1], 'w') as outfile:
dump_dags(outfile)
7 changes: 5 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ export AIRFLOW__CORE__DAGS_FOLDER=${GITHUB_WORKSPACE}/
export AIRFLOW__CORE__PLUGINS_FOLDER=${GITHUB_WORKSPACE}/plugins/
export AIRFLOW__CORE__LOGS_FOLDER="/tmp/logs/"
export FERNET_KEY=$(openssl rand -base64 32)
cat $GITHUB_EVENT_PATH
echo Base ref is $GITHUB_BASE_REF
airflow initdb
python /main.py
python /dump_dags.py /tmp/current.txt
git checkout $GITHUB_BASE_REF
python /dump_dags.py /tmp/base.txt
diff=$(diff -u /tmp/base.txt /tmp/current.txt)

0 comments on commit fad04f4

Please sign in to comment.