-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add docker workflow * Add CodeQL workflow * Add Rust workflow * Add python workflow
- Loading branch information
1 parent
04687a6
commit eb411d5
Showing
6 changed files
with
163 additions
and
0 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,46 @@ | ||
name: codeql | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
schedule: | ||
- cron: '32 18 * * 3' | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze (${{ matrix.language }}) | ||
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} | ||
permissions: | ||
security-events: write | ||
packages: read | ||
actions: read | ||
contents: read | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- language: python | ||
build-mode: none | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v3 | ||
with: | ||
languages: ${{ matrix.language }} | ||
build-mode: ${{ matrix.build-mode }} | ||
- if: matrix.build-mode == 'manual' | ||
shell: bash | ||
run: | | ||
echo 'If you are using a "manual" build mode for one or more of the' \ | ||
'languages you are analyzing, replace this with the commands to build' \ | ||
'your code, for example:' | ||
echo ' make bootstrap' | ||
echo ' make release' | ||
exit 1 | ||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v3 | ||
with: | ||
category: "/language:${{matrix.language}}" |
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,53 @@ | ||
name: news/docker | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["news/graphql", "news/machine_learning", "codeql"] | ||
types: | ||
- completed | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
|
||
jobs: | ||
deploy: | ||
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'master' }} | ||
name: Publish news | ||
runs-on: ubuntu-latest | ||
permissions: write-all | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Get GraphQL tag | ||
id: "get-graphql-tag" | ||
shell: "bash" | ||
run: | | ||
echo PKG_VERSION=$(awk -F ' = ' '$1 ~ /version/ { gsub(/["]/, "", $2); printf("%s",$2) }' graphql/Cargo.toml) >> $GITHUB_OUTPUT | ||
- name: Build GraphQL image | ||
run: | | ||
docker build . -f docker/api/Dockerfile -t ghcr.io/gravitalia/news-api:latest . | ||
docker push ghcr.io/lubmminy/polymath:latest | ||
docker tag ghcr.io/gravitalia/news-graphql:latest ghcr.io/gravitalia/news-api:${{ steps.get-graphql-tag.outputs.PKG_VERSION }} | ||
docker push ghcr.io/lubmminy/polymath:${{ steps.get-graphql-tag.outputs.PKG_VERSION }} | ||
- name: Get ML tag | ||
id: "get-ml-tag" | ||
shell: "bash" | ||
run: | | ||
echo PKG_VERSION=$(awk -F ' = ' '/^version/ { gsub(/["]/, "", $2); print $2 }' machine_learning/pyproject.toml) >> $GITHUB_OUTPUT | ||
- name: Build ML API image | ||
run: | | ||
docker build . -f docker/ml/Dockerfile -t ghcr.io/gravitalia/news-ml:latest . | ||
docker tag ghcr.io/gravitalia/news-ml:latest ghcr.io/gravitalia/news-ml:${{ steps.get-ml-tag.outputs.PKG_VERSION }} | ||
- name: Publish images | ||
run: | | ||
docker push ghcr.io/gravitalia/news-api:latest | ||
docker push ghcr.io/gravitalia/news-api:${{ steps.get-graphql-tag.outputs.PKG_VERSION }} | ||
docker push ghcr.io/gravitalia/news-ml:latest | ||
docker push ghcr.io/gravitalia/news-ml:${{ steps.get-ml-tag.outputs.PKG_VERSION }} |
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,24 @@ | ||
name: news/machine_learning | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.9"] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: pip | ||
- name: Install dependencies | ||
working-directory: ./machine_learning | ||
run: | | ||
python -m pip install --upgrade pip setuptools wheel | ||
python -m pip install . | ||
#- name: Test | ||
# Add test later. |
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,32 @@ | ||
name: news/graphql | ||
|
||
on: [push] | ||
|
||
jobs: | ||
graphql: | ||
name: cargo build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Cache Cargo registry | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cargo | ||
target | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-cargo- | ||
- name: Install Protoc | ||
uses: arduino/setup-protoc@v3 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Initialize Rust toolchain | ||
uses: dtolnay/rust-toolchain@stable | ||
- name: Test GraphQL API | ||
working-directory: ./graphql | ||
run: cargo test --all-features | ||
- name: Clippy | ||
working-directory: ./graphql | ||
run: cargo clippy |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from setuptools import setup, find_packages | ||
|
||
setup( | ||
name="news", | ||
version="0.1.0", | ||
packages=find_packages(include=["rest", "rest.*"]), | ||
) |