Skip to content

fix duplicate addition in queue #66

fix duplicate addition in queue

fix duplicate addition in queue #66

Workflow file for this run

name: Python CI
on:
push:
branches:
- "*"
paths:
- "src/**/*.py"
- "requirements.txt"
- "Dockerfile"
- ".github/workflows/compile.yml"
pull_request:
branches:
- "*"
paths:
- "src/**/*.py"
- "requirements.txt"
- "Dockerfile"
- ".github/workflows/compile.yml"
jobs:
compile:
name: "Compile Python 3.11"
runs-on: ubuntu-latest
outputs:
json: ${{ steps.version.outputs.json }}
version: ${{ steps.version.outputs.version }}
commit_id: ${{ steps.version.outputs.commit_id }}
last_author: ${{ steps.version.outputs.last_author }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test compilation
run: |
python -m compileall ./src
- name: Save version
run: |
FULL_JSON=$(python src/pyramid --version)
echo "json=$(echo $FULL_JSON | jq -c)" >> $GITHUB_OUTPUT
echo "version=$(echo $FULL_JSON | jq -r '.version')" >> $GITHUB_OUTPUT
echo "commit_id=$(echo $FULL_JSON | jq -r '.git_info.commit_id')" >> $GITHUB_OUTPUT
echo "last_author=$(echo $FULL_JSON | jq -r '.git_info.last_author')" >> $GITHUB_OUTPUT
id: version
version_compatibility:
name: "Compile Python"
runs-on: ubuntu-latest
needs: compile
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: "${{ matrix.python-version }}"
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-${{ matrix.python-version }}
restore-keys: |
${{ runner.os }}-pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test compilation
run: |
python -m compileall ./src
docker_push:
name: "Docker Push"
needs: compile
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set git info
run: |
echo '${{ needs.compile.outputs.json }}' | jq -r '.git_info' > git_info.json
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set Docker Tag
run: |
if [ ${{ github.ref }} = 'refs/heads/main' ]; then
echo "tag=latest" >> $GITHUB_OUTPUT
elif [ ${{ github.ref }} = 'refs/heads/pre-prod' ]; then
echo "tag=pre-prod" >> $GITHUB_OUTPUT
else
echo "tag=dev" >> $GITHUB_OUTPUT
fi
id: set_tag
- name: Build and push PROD
if: steps.set_tag.outputs.tag == 'latest'
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/pyramid:${{ steps.set_tag.outputs.tag }},
${{ secrets.DOCKERHUB_USERNAME }}/pyramid:${{ needs.compile.outputs.version }},
${{ secrets.DOCKERHUB_USERNAME }}/pyramid:${{ needs.compile.outputs.version }}-${{ needs.compile.outputs.commit_id }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push DEV
if: steps.set_tag.outputs.tag != 'latest'
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/pyramid:${{ steps.set_tag.outputs.tag }},
${{ secrets.DOCKERHUB_USERNAME }}/pyramid:${{ needs.compile.outputs.version }}-${{ needs.compile.outputs.commit_id }}
cache-from: type=gha
cache-to: type=gha,mode=max