This repository has been archived by the owner on Jul 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
global: fix Dockerfile and gh-actions
- Loading branch information
Showing
8 changed files
with
183 additions
and
87 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Build | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
ref: | ||
description: The reference to build | ||
type: string | ||
required: true | ||
image: | ||
description: The name of the image to build | ||
type: string | ||
required: true | ||
context: | ||
description: The context used to build the image | ||
type: string | ||
required: true | ||
dockerfile: | ||
description: The path to the Dockerfile | ||
type: string | ||
required: false | ||
outputs: | ||
image-id: | ||
description: The ID of image that has been built | ||
value: ${{ jobs.build.outputs.image-id }} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
image-id: ${{ steps.build.outputs.image-id }} | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.ref }} | ||
|
||
- id: build | ||
name: Build and push | ||
uses: cern-sis/gh-workflows/.github/actions/[email protected] | ||
with: | ||
image: ${{ inputs.image }} | ||
context: ${{ inputs.context }} | ||
dockerfile: ${{ inputs.dockerfile }} | ||
registry: registry.cern.ch | ||
cache: false | ||
tags: | | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=ref,event=tag | ||
username: ${{ secrets.HARBOR_USERNAME }} | ||
password: ${{ secrets.HARBOR_PASSWORD }} |
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,21 @@ | ||
name: Lint | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
ref: | ||
description: The reference to build | ||
type: string | ||
required: true | ||
|
||
jobs: | ||
linter: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.ref }} | ||
|
||
- name: Pre-commit check | ||
uses: pre-commit/[email protected] |
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,16 @@ | ||
name: Pull request main | ||
|
||
on: | ||
pull_request_target: | ||
branches: [main] | ||
|
||
jobs: | ||
lint: | ||
uses: ./.github/workflows/lint.yml | ||
with: | ||
ref: ${{ github.ref }} | ||
test: | ||
uses: ./.github/workflows/test.yml | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
secrets: inherit |
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,31 @@ | ||
name: Push main | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
lint: | ||
uses: ./.github/workflows/lint.yml | ||
with: | ||
ref: ${{ github.ref }} | ||
test: | ||
uses: ./.github/workflows/test.yml | ||
with: | ||
ref: ${{ github.ref }} | ||
secrets: inherit | ||
deploy: | ||
needs: [lint, test] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: send event | ||
uses: cern-sis/gh-workflows/.github/actions/[email protected] | ||
with: | ||
event-type: update | ||
images: | | ||
cern-sis/inspire/workflows@${{ needs.test.outputs.image-id }} | ||
token: ${{ secrets.PAT_FIRE_EVENTS_ON_CERN_SIS_KUBERNETES }} |
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,59 @@ | ||
name: Tests | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
ref: | ||
description: The reference to build | ||
type: string | ||
required: true | ||
outputs: | ||
image-id: | ||
description: The ID of image that has been built | ||
value: ${{ jobs.build.outputs.image-id }} | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
build: | ||
uses: ./.github/workflows/build.yml | ||
with: | ||
ref: ${{ inputs.ref }} | ||
image: cern-sis/inspire/backoffice | ||
context: . | ||
dockerfile: ./compose/production/django/Dockerfile | ||
secrets: inherit | ||
test: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
services: | ||
redis: | ||
image: redis | ||
ports: | ||
- 6379:6379 | ||
postgres: | ||
image: postgres:13 | ||
env: | ||
POSTGRES_USER: airflow | ||
POSTGRES_PASSWORD: airflow | ||
POSTGRES_DB: airflow | ||
ports: | ||
- 5431:5431 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.ref }} | ||
|
||
- name: Test | ||
run: > | ||
docker run | ||
-v "$(pwd)"/tests:/opt/airflow/tests | ||
-v "$(pwd)"/dags:/opt/airflow/dags | ||
-v "$(pwd)"/airflow.cfg:/opt/airflow/airflow.cfg | ||
-v "$(pwd)"/requirements-test.txt:/opt/airflow/requirements-test.txt | ||
-v "$(pwd)"/data:/opt/airflow/data | ||
${{ inputs.image }} | ||
bash -c "pip install -r requirements-text.txt && airflow db init && pytest /opt/airflow/tests" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,6 @@ | ||
FROM apache/airflow:2.8.3-python3.11 | ||
|
||
USER root | ||
COPY --chown=airflow:root dags /opt/airflow/dags/ | ||
COPY --chown=airflow:root requirements.txt ./requirements.txt | ||
|
||
RUN mkdir -p ${AIRFLOW_HOME} && chown -R airflow: ${AIRFLOW_HOME} | ||
|
||
USER airflow | ||
|
||
RUN airflow db init | ||
COPY requirements.txt ./requirements.txt | ||
COPY requirements-test.txt ./requirements-test.txt | ||
RUN pip install --no-cache-dir --upgrade --user -r requirements.txt -r requirements-test.txt | ||
RUN pip install --no-cache-dir "apache-airflow==${AIRFLOW_VERSION}" -r requirements.txt |
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