Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking workflow #91

Merged
merged 3 commits into from
Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/github-actions-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow runs some checks on the abbreviation file
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: BDNS validation checks

on:
push:
branches: [ master ]
paths:
- ./**

pull_request:
branches: [ master ]
paths:
- ./**

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
working-directory: ./tools/

- name: Check for duplicates
run: |
python check-duplicates.py --input ../BDNS_Abbreviations_Register.csv
working-directory: ./tools/
50 changes: 50 additions & 0 deletions tools/check-duplicates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import argparse
from pyfiglet import Figlet
from os.path import exists
from sys import exit
from pandas import read_csv, DataFrame

__author__ = "Francesco Anselmo"
__copyright__ = "Copyright 2022, Francesco Anselmo"
__credits__ = ["Francesco Anselmo"]
__license__ = "Apache-2.0"
__version__ = "0.1"
__maintainer__ = "Francesco Anselmo"
__email__ = "francesco.anselmo@gmail.com"
__status__ = "Dev"

def show_title():
"""Show the program title
"""
f1 = Figlet(font='standard')
print(f1.renderText('BDNS check duplicates'))

def check_duplicates(filename):
df = read_csv(filename)
ids = df["asset_abbreviation"]
dups = ids.duplicated()
result = df[ids.isin(ids[dups])]
if len(result)>0:
print("Number of duplicates found in abbreviation file: %s" % len(result))
print(result)
exit(1)
else:
print("No duplicates found in abbreviation file")
exit(0)

def main():
show_title()
parser = argparse.ArgumentParser()
parser.add_argument("-i","--input", default="abbreviations.csv", help="Input CSV file to check for duplicates")
args = parser.parse_args()
if exists(args.input):
check_duplicates(args.input)
else:
print("File %s does not exist" % args.input)
exit(1)

if __name__ == "__main__":
main()
2 changes: 2 additions & 0 deletions tools/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pyfiglet
pandas
Loading