Skip to content

Add CI steps to support 12 factor charm deployment #428

Add CI steps to support 12 factor charm deployment

Add CI steps to support 12 factor charm deployment #428

Workflow file for this run

name: PR checks
on: pull_request
env:
FLASK_SECRET_KEY: insecure_test_key
SECRET_KEY: insecure_test_key
jobs:
build-and-publish:
name: Build and Publish Rock Image
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v3
- name: Build Assets
run: |
yarn install
yarn run build-css
yarn run build-js
- name: Setup LXD
uses: canonical/setup-lxd@main
- name: Checkout Rockcraft
uses: actions/checkout@v2
with:
repository: canonical/rockcraft
path: rockcraft
ref: feature/12f
- name: Rockcraft Git Hash
id: rockcraft-git
working-directory: ./rockcraft
run: echo "SHA=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
- name: Restore Rockcraft Snap Cache
id: cache-rockcraft-snap
uses: actions/cache/restore@v3
with:
path: ./rockcraft/rockcraft*.snap
key: rockcraft-${{ steps.rockcraft-git.outputs.SHA }}.snap
- name: Build Rockcraft
if: steps.cache-rockcraft-snap.outputs.cache-hit != 'true'
working-directory: ./rockcraft
run: |
sudo snap install snapcraft --classic
snapcraft --use-lxd
- name: Cache Rockcraft Snap Cache
uses: actions/cache/save@v3
with:
path: ./rockcraft/rockcraft*.snap
key: ${{ steps.cache-rockcraft-snap.outputs.cache-primary-key }}
- name: Install Rockcraft
working-directory: ./rockcraft
run: |
sudo snap install rockcraft*.snap --classic --dangerous
- name: Build Rock Image
run: |
export ROCKCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS=true
rockcraft pack
- name: Publish Rock Image
run: >-
skopeo --insecure-policy copy
oci-archive:$(ls *.rock)
docker://ghcr.io/canonical/dqlite.io:$(git rev-parse --short HEAD)
--dest-creds "canonical:${{ secrets.GITHUB_TOKEN }}"
run-dotrun:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install dotrun
uses: canonical/install-dotrun@main
- name: Install dependencies
run: dotrun install
- name: Build assets
run: dotrun build
- name: Test site
run: dotrun & curl --head --fail --retry-delay 1 --retry 30 --retry-connrefused http://localhost:8037
lint-python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install node dependencies
run: yarn install --immutable
- name: Install python dependencies
run: |
python3 -m pip install --upgrade pip
sudo pip3 install flake8 black
- name: Lint python
run: yarn lint-python
lint-scss:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: yarn install --immutable
- name: Lint scss
run: yarn lint-scss
test-python:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Install requirements
run: |
sudo apt-get update && sudo apt-get install --yes python3-setuptools
sudo pip3 install -r requirements.txt
- name: Install dependencies
run: sudo pip3 install coverage
- name: Install node dependencies
run: yarn install --immutable
- name: Build resources
run: yarn build
- name: Run tests with coverage
run: |
coverage run --source=. -m unittest discover tests
bash <(curl -s https://codecov.io/bash) -cF python
inclusive-naming-check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Check inclusive naming
uses: canonical-web-and-design/inclusive-naming@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-check
fail-on-error: true