-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
964 additions
and
653 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Python application | ||
name: Python application and Docker image CI | ||
|
||
on: | ||
push: | ||
|
@@ -32,13 +32,20 @@ jobs: | |
sudo cpan -f -i Email::Outlook::Message | ||
- name: Run tests | ||
env: | ||
PYTHONPATH: src | ||
run: | | ||
pytest | ||
pytest --cov=mailparser --cov-report=xml | ||
python -m mailparser -v | ||
python -m mailparser -h | ||
mail-parser -f tests/mails/mail_malformed_3 -j | ||
cat tests/mails/mail_malformed_3 | mail-parser -k -j | ||
- name: Run pre-commit | ||
if: matrix.python-version == '3.10' | ||
run: | | ||
make pre-commit | ||
- name: Report to Coveralls | ||
if: matrix.python-version == '3.10' | ||
uses: coverallsapp/[email protected] | ||
|
@@ -57,4 +64,97 @@ jobs: | |
name: build-artifacts | ||
path: | | ||
dist/mail-parser-*.tar.gz | ||
dist/mail_parser-*.whl | ||
dist/mail_parser-*.whl | ||
- name: Publish to PyPI | ||
if: matrix.python-version == '3.10' && startsWith(github.ref, 'refs/tags/') | ||
uses: pypa/[email protected] | ||
with: | ||
user: ${{ secrets.PYPI_USERNAME }} | ||
password: ${{ secrets.PYPI_PASSWORD }} | ||
|
||
docker: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log in to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: docker.io | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Extract branch or tag name | ||
id: extract_ref | ||
run: | | ||
if [ -n "${GITHUB_HEAD_REF}" ]; then | ||
REF_NAME=${GITHUB_HEAD_REF} | ||
else | ||
REF_NAME=$(git describe --tags --exact-match 2>/dev/null || git rev-parse --abbrev-ref HEAD) | ||
fi | ||
echo "REF_NAME=${REF_NAME,,}" >> $GITHUB_ENV | ||
- name: Debug REF_NAME | ||
run: echo "REF_NAME=${{ env.REF_NAME }}" | ||
|
||
- name: Build and push Docker image on GitHub Container Registry | ||
run: | | ||
cd docker | ||
IMAGE_NAME=ghcr.io/ghcr.io/spamscope/mail-parser/mailparser | ||
if [[ $GITHUB_REF == refs/tags/* ]]; then | ||
TAG=${GITHUB_REF#refs/tags/} | ||
docker build \ | ||
--label "org.opencontainers.image.source=${{ github.repositoryUrl }}" \ | ||
--label "org.opencontainers.image.description=Easy way to pass from raw mail to Python object" \ | ||
--label "org.opencontainers.image.licenses=Apache-2.0" \ | ||
--build-arg BRANCH=$TAG \ | ||
-t $IMAGE_NAME:$TAG \ | ||
-t $IMAGE_NAME:latest . | ||
docker push $IMAGE_NAME:$TAG | ||
docker push $IMAGE_NAME:latest | ||
else | ||
docker build \ | ||
--label "org.opencontainers.image.source=${{ github.repositoryUrl }}" \ | ||
--label "org.opencontainers.image.description=Easy way to pass from raw mail to Python object" \ | ||
--label "org.opencontainers.image.licenses=Apache-2.0" \ | ||
--build-arg BRANCH=${{ env.REF_NAME }} \ | ||
-t $IMAGE_NAME:develop . | ||
docker push $IMAGE_NAME:develop | ||
fi | ||
- name: Build and push Docker image on Docker Hub | ||
run: | | ||
cd docker | ||
IMAGE_NAME=docker.io/${{ secrets.DOCKER_USERNAME }}/spamscope-mail-parser | ||
if [[ $GITHUB_REF == refs/tags/* ]]; then | ||
TAG=${GITHUB_REF#refs/tags/} | ||
docker build \ | ||
--label "org.opencontainers.image.source=${{ github.repositoryUrl }}" \ | ||
--label "org.opencontainers.image.description=Easy way to pass from raw mail to Python object" \ | ||
--label "org.opencontainers.image.licenses=Apache-2.0" \ | ||
--build-arg BRANCH=$TAG \ | ||
-t $IMAGE_NAME:$TAG \ | ||
-t $IMAGE_NAME:latest . | ||
docker push $IMAGE_NAME:$TAG | ||
docker push $IMAGE_NAME:latest | ||
else | ||
docker build \ | ||
--label "org.opencontainers.image.source=${{ github.repositoryUrl }}" \ | ||
--label "org.opencontainers.image.description=Easy way to pass from raw mail to Python object" \ | ||
--label "org.opencontainers.image.licenses=Apache-2.0" \ | ||
--build-arg BRANCH=${{ env.REF_NAME }} \ | ||
-t $IMAGE_NAME:develop . | ||
docker push $IMAGE_NAME:develop | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v5.0.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-yaml | ||
- id: check-added-large-files | ||
args: ['--maxkb=5000'] | ||
- id: check-case-conflict | ||
- id: check-json | ||
- id: check-merge-conflict | ||
- id: detect-aws-credentials | ||
args: ["--allow-missing-credentials"] | ||
- id: detect-private-key | ||
- id: mixed-line-ending | ||
- id: check-ast | ||
|
||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
# Ruff version. | ||
rev: v0.7.3 | ||
hooks: | ||
# Run the linter. | ||
- id: ruff | ||
args: [ --fix ] | ||
# Run the formatter. | ||
- id: ruff-format |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
FROM python | ||
FROM python:3.10-slim-bullseye | ||
ENV MAIL_PARSER_PATH=/tmp/mailparser | ||
ARG BRANCH=develop | ||
RUN apt-get -yqq update; \ | ||
apt-get -yqq --no-install-recommends install libemail-outlook-message-perl; \ | ||
apt-get clean; \ | ||
rm -rf /var/lib/apt/lists/*; \ | ||
git clone -b $BRANCH --single-branch https://github.com/SpamScope/mail-parser.git $MAIL_PARSER_PATH; \ | ||
cd $MAIL_PARSER_PATH && python setup.py install | ||
ENTRYPOINT ["mailparser"] | ||
RUN apt-get -yqq update && \ | ||
apt-get -yqq --no-install-recommends install libemail-outlook-message-perl git && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* && \ | ||
git clone -b ${BRANCH} --single-branch https://github.com/SpamScope/mail-parser.git ${MAIL_PARSER_PATH} && \ | ||
cd ${MAIL_PARSER_PATH} && \ | ||
python setup.py install | ||
ENTRYPOINT ["mail-parser"] | ||
CMD ["-h"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
[![Build Status](https://travis-ci.org/SpamScope/mail-parser.svg?branch=develop)](https://travis-ci.org/SpamScope/mail-parser) | ||
[![](https://images.microbadger.com/badges/image/fmantuano/spamscope-mail-parser.svg)](https://microbadger.com/images/fmantuano/spamscope-mail-parser "Get your own image badge on microbadger.com") | ||
[![PyPI - Version](https://img.shields.io/pypi/v/mail-parser)](https://pypi.org/project/mail-parser/) | ||
[![Coverage Status](https://coveralls.io/repos/github/SpamScope/mail-parser/badge.svg?branch=develop)](https://coveralls.io/github/SpamScope/mail-parser?branch=develop) | ||
[![PyPI - Downloads](https://img.shields.io/pypi/dm/mail-parser?color=blue)](https://pypistats.org/packages/mail-parser) | ||
|
||
![SpamScope](https://raw.githubusercontent.com/SpamScope/spamscope/develop/docs/logo/spamscope.png) | ||
|
||
# fmantuano/spamscope-mail-parser | ||
|
||
This Dockerfile represents a Docker image that encapsulates mail-parser. The [official image](https://hub.docker.com/r/fmantuano/spamscope-mail-parser/) is on Docker Hub. | ||
This Dockerfile represents a Docker image that encapsulates `mail-parser`. The [official image](https://hub.docker.com/r/fmantuano/spamscope-mail-parser/) is on Docker Hub. | ||
|
||
To run this image after installing Docker, use a command like this: | ||
|
||
``` | ||
```shell | ||
sudo docker run -i -t --rm -v ~/mails:/mails fmantuano/spamscope-mail-parser | ||
``` | ||
|
||
This command runs mail-parser help as default, but you can use all others options. | ||
This command runs `mail-parser` help as default, but you can use all others options. | ||
|
||
To share the "mails" directory between your host and the container, create a "mails" directory on your host. | ||
|
||
There also is an example of `docker-compose` | ||
There also is an example of `docker-compose` | ||
|
||
From the `docker-compose.yml` directory, run: | ||
|
||
``` | ||
```shell | ||
$ sudo docker-compose up | ||
``` | ||
|
||
The provided ```docker-compose.yml``` file is configured to: | ||
The provided `docker-compose.yml` file is configured to: | ||
|
||
- Mount your host's `~/mails/` folder from your source tree inside the container at `/mails/` (read-only). | ||
- A command line test example. | ||
|
||
See the ```docker-compose.yml``` to view and tweak the launch parameters. | ||
See the `docker-compose.yml` to view and tweak the launch parameters. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[build-system] | ||
requires = ["setuptools >= 40.6.0", "wheel"] | ||
build-backend = "setuptools.build_meta" | ||
build-backend = "setuptools.build_meta" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,4 +67,4 @@ addopts = | |
--cov-report=html | ||
--junitxml=junit.xml | ||
--verbose | ||
testpaths = tests | ||
testpaths = tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,4 @@ | |
import setuptools | ||
|
||
if __name__ == "__main__": | ||
setuptools.setup() | ||
setuptools.setup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.