Skip to content
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
55 changes: 18 additions & 37 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,26 @@
name: Build Base Image & Push to GHCR
on:
push:
branches:
- master
pull_request:

jobs:
build_mdx:
test_mdx:
runs-on: ubuntu-latest
name: Build & Test
name: Run Unit Tests
steps:
- uses: actions/checkout@v2
- uses: dorny/paths-filter@v2
id: filter
- uses: actions/checkout@v5
- name: Set up python
uses: actions/setup-python@v5
with:
filters: |
mdx_base:
- 'mdx_base/**'

- name: check logic
if: steps.filter.outputs.mdx_base == 'true'
python-version: '3.12'
- name: Install dependencies
run: |
echo "I am check logic"
echo ${{steps.filter.outputs.mdx_base}}
ls -al

- uses: docker/login-action@v2
name: docker login
with:
registry: ghcr.io
username: USERNAME
password: ${{secrets.GITHUB_TOKEN}}
- uses: docker/build-push-action@v3
if: steps.filter.outputs.mdx_base == 'true'
name: Build MDX base docker
with:
context: ./mdx_base
tags: ghcr.io/ghrcdaac/mdx:base
push: true
- uses: docker/build-push-action@v3
name: Build docker
with:
context: .
tags: ghcr.io/ghrcdaac/mdx:latest

python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Install xmllint
run: |
sudo apt install -y libxml2-utils
- name: Test with pytest
run: |
cd mdx
python -m pytest test --doctest-modules --junitxml=./test_results/test_metadata_extractor.xml --cov=com --cov-report=xml --cov-report=html
13 changes: 11 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
FROM ghcr.io/ghrcdaac/mdx:base
FROM public.ecr.aws/lambda/python:3.12

RUN dnf install -y gcc && \
dnf install -y git

RUN dnf install -y libxml2

RUN dnf install -y nano

ARG stage

COPY requirements*.txt /tmp/

RUN pip install --upgrade pip

RUN pip install --upgrade --force-reinstall -r /tmp/requirements.txt --target "${LAMBDA_TASK_ROOT}"

ADD mdx ${LAMBDA_TASK_ROOT}

# Only if stage is other than dev
RUN if [ "$stage" != "prod" ] ; then \
pip install -r /tmp/requirements-dev.txt && \
python -m pytest --junitxml=./test_results/test_metadata_extractor.xml test; \
python -m pytest test --doctest-modules --junitxml=./test_results/test_metadata_extractor.xml --cov=com --cov-report=xml --cov-report=html; \
fi

RUN rm -rf test
Expand Down
3 changes: 1 addition & 2 deletions build_push_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function update_lambda_or_skip_local() {
echo "Lambda ${2}-${3} Exists"
echo "Updating Lambda ${2}-${3}"
docker_image_name=$1.dkr.ecr.$AWS_REGION.amazonaws.com/$REPO_NAME
aws lambda update-function-code \
AWS_PAGER="" aws lambda update-function-code \
--function-name $2-$3 \
--image-uri ${docker_image_name}:latest \
--region ${AWS_REGION} \
Expand All @@ -42,7 +42,6 @@ fi
AWS_ACCOUNT_ID=$(get_account_id $AWS_PROFILE)


docker build -t ghcr.io/ghrcdaac/mdx:base ./mdx_base
docker build -t ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/$REPO_NAME .
check_exit

Expand Down
12 changes: 0 additions & 12 deletions mdx_base/Dockerfile

This file was deleted.

1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ nose-testconfig==0.10
nose==1.3.7
nosexcover==1.0.11
pytest==9.0.2
pytest-cov==7.0.0