Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert base to snap from deb #9

Merged
merged 12 commits into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: Build
name: Build ROCK

on:
workflow_call:
pull_request:

jobs:
build:
Expand All @@ -21,5 +20,5 @@ jobs:
- name: Upload locally built ROCK artifact
uses: actions/upload-artifact@v3
with:
name: mysql-server-rock
path: "mysql-server_*.rock"
name: charmed-mysql-rock
path: "charmed-mysql_*.rock"
41 changes: 41 additions & 0 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Operator Tests

on:
pull_request:
workflow_call:
workflow_dispatch:

jobs:
build:
uses: ./.github/workflows/build.yaml
integration:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
env:
- integration-charm
- integration-database-relation
- integration-osm-mysql
- integration-replication
- integration-self-healing
- integration-tls
- integration-backups
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup operator environment
uses: charmed-kubernetes/actions-operator@main
with:
provider: microk8s
# This is needed until
# https://bugs.launchpad.net/juju/+bug/1977582 is fixed
bootstrap-options: "--agent-version 2.9.29"
- uses: actions/download-artifact@v3
with:
name: charmed-mysql-rock
- name: Install tox
run: python3 -m pip install tox
- name: Integration Tests
run: sg microk8s -c "tox -e ${{ matrix.env }}"
16 changes: 16 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Lint
on:
pull_request:
workflow_call:
workflow_dispatch:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install tox
run: python3 -m pip install tox
- name: YAML Lint
run: tox -e lint
15 changes: 8 additions & 7 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
name: Publish ROCK
on:
push:
branches:
- 8.0-20.04
- '*.*/stable'
workflow_dispatch:
branches:
- 8.0-20.04
- '*.*/stable'

jobs:
build:
uses: ./.github/workflows/build.yaml
uses: ./.github/workflows/build.yaml
publish:
needs: build
runs-on: ubuntu-latest
Expand All @@ -29,7 +30,7 @@ jobs:
sudo snap install yq
- uses: actions/download-artifact@v3
with:
name: mysql-server-rock
name: charmed-mysql-rock

- name: Login to Docker Hub
uses: docker/login-action@v1
Expand All @@ -43,6 +44,6 @@ jobs:
sudo skopeo \
--insecure-policy \
copy \
oci-archive:"mysql-server_${version}_amd64.rock" \
docker-daemon:"dataplatformoci/charmed-mysql-server:${version}"
docker push "dataplatformoci/charmed-mysql-server:${version}"
oci-archive:"charmed-mysql_${version}_amd64.rock" \
docker-daemon:"dataplatformoci/charmed-mysql:${version}"
docker push "dataplatformoci/charmed-mysql:${version}"
3 changes: 2 additions & 1 deletion .github/workflows/sync_issue_to_jira.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ on:
jobs:
sync:
name: Sync GitHub issue to Jira
uses: canonical/data-platform-workflows/.github/workflows/sync_issue_to_jira.yaml@v1
uses: "canonical/data-platform-workflows/\
.github/workflows/sync_issue_to_jira.yaml@v1"
with:
jira-component-name: mysql-k8s
secrets:
Expand Down
61 changes: 19 additions & 42 deletions rockcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ base: ubuntu:22.04 # the base environment for this ROCK
version: '8.0.31' # just for humans. Semantic versioning is recommended
summary: Charmed MySQL ROCK OCI # 79 char long summary
description: |
MySQL built from the official MySQL package
from the MySQL repository and installs
mysql-shell. For more information on ROCKs, visit
MySQL built from the official MySQL package
from the MySQL repository and installs
mysql-shell. For more information on ROCKs, visit
the https://github.com/canonical/rockcraft.
license: Apache-2.0 # your application's SPDX license
cmd:
Expand All @@ -21,58 +21,35 @@ platforms: # The platforms this ROCK should be built on and run on
amd64:

parts:
mysql-repo:
charmed-mysql:
plugin: nil
override-pull: |
export DEBIAN_FRONTEND=noninteractive
export CONFIG_VERSION="0.8.22-1"
apt-get update
apt-get install -y wget lsb-release gnupg
wget -q https://dev.mysql.com/get/mysql-apt-config_${CONFIG_VERSION}_all.deb \
-O /tmp/mysql-apt-config_${CONFIG_VERSION}_all.deb
dpkg -i /tmp/mysql-apt-config_${CONFIG_VERSION}_all.deb
apt-get update
percona-repo:
plugin: nil
override-pull: |
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y wget lsb-release
wget https://repo.percona.com/apt/percona-release_latest.$(lsb_release -sc)_all.deb
dpkg -i percona-release_latest.$(lsb_release -sc)_all.deb
apt-get update
packages-deb:
plugin: nil
after:
- mysql-repo
- percona-repo
stage-packages:
- mysql-server
- mysql-router
- mysql-shell
- percona-xtrabackup-80
- util-linux
stage-snaps:
- charmed-mysql/8.0/edge
override-stage: |
craftctl default
mkdir -p $CRAFT_STAGE/var/lib/mysql
ln -sf /root/parts/packages-deb/install/usr/lib/x86_64-linux-gnu/libnuma.so.1 /usr/lib/x86_64-linux-gnu/libnuma.so.1
ln -sf /root/parts/packages-deb/install/usr/lib/x86_64-linux-gnu/libaio.so.1 /usr/lib/x86_64-linux-gnu/libaio.so.1
ln -sf $CRAFT_STAGE/usr/lib/x86_64-linux-gnu/libnuma.so.1 \
/usr/lib/x86_64-linux-gnu/libnuma.so.1
ln -sf $CRAFT_STAGE/usr/lib/x86_64-linux-gnu/libaio.so.1 \
/usr/lib/x86_64-linux-gnu/libaio.so.1
rm -rf /var/lib/mysql/
mysqld --initialize
cp -r /var/lib/mysql $CRAFT_STAGE/var/lib
chown 1000:1000 $CRAFT_STAGE/var/lib/mysql
chown 584788:584788 $CRAFT_STAGE/var/lib/mysql
override-prime: |
craftctl default
mv -f $CRAFT_PRIME/etc/mysql/mysql.cnf $CRAFT_PRIME/etc/mysql/my.cnf
mkdir -p $CRAFT_PRIME/var/log/mysql
chown -R 1000:1000 $CRAFT_PRIME/var/log/mysql
chown -R 584788:584788 $CRAFT_PRIME/var/log/mysql
non-root-user:
plugin: nil
after: [packages-deb]
after: [charmed-mysql]
overlay-script: |
# Create a user in the $CRAFT_OVERLAY chroot
groupadd -R $CRAFT_OVERLAY -g 1000 mysql
useradd -R $CRAFT_OVERLAY -M -r -g mysql -u 1000 mysql
groupadd -R $CRAFT_OVERLAY -g 584788 mysql
useradd -R $CRAFT_OVERLAY -M -r -g mysql -u 584788 mysql
override-prime: |
craftctl default
# This is only needed until this bug is resolved with pebble
Expand All @@ -82,10 +59,10 @@ parts:
for i in "${array[@]}"
do
cp /etc/skel/"$i" $CRAFT_PRIME/home/mysql
chown 1000:1000 $CRAFT_PRIME/home/mysql/"$i"
chown 584788 $CRAFT_PRIME/home/mysql/"$i"
done
mkdir -p $CRAFT_PRIME/var/lib/mysql-files
mkdir -p $CRAFT_PRIME/var/run/mysqld
chown -R 1000:1000 $CRAFT_PRIME/var/lib/mysql*
chown -R 1000:1000 $CRAFT_PRIME/var/run/mysqld
chown -R 1000:1000 $CRAFT_PRIME/etc/mysql
chown -R 584788 $CRAFT_PRIME/var/lib/mysql*
chown -R 584788 $CRAFT_PRIME/var/run/mysqld
chown -R 584788 $CRAFT_PRIME/etc/mysql
109 changes: 109 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
[tox]
requires =
tox>=4
env_list = lint, integration

[testenv]
setenv =
version=8.0.31
repo=https://github.com/canonical/mysql-k8s-operator.git
base-name=docker.io/dataplatformoci/charmed-mysql

[testenv:lint]
description = run linters
skip_install = true
deps =
yamllint
commands =
yamllint --no-warnings rockcraft.yaml .github

[testenv:integration-charm]
description = run operator integration tests
skip_install = true
allowlist_externals =
tox
microk8s
bash
commands =
bash -ec 'if ! [ -f charmed-mysql_{env:version}_amd64.rock ]; then rockcraft pack; fi' {posargs}
microk8s ctr image import charmed-mysql_{env:version}_amd64.rock --base-name {env:base-name}
bash -ec 'if ! [ -d operator ]; then git clone {env:repo} operator; fi' {posargs}
tox --workdir operator -c operator -e integration-charm

[testenv:integration-database-relation]
description = run operator integration tests
skip_install = true
allowlist_externals =
tox
microk8s
bash
commands =
bash -ec 'if ! [ -f charmed-mysql_{env:version}_amd64.rock ]; then rockcraft pack; fi' {posargs}
microk8s ctr image import charmed-mysql_{env:version}_amd64.rock --base-name {env:base-name}
bash -ec 'if ! [ -d operator ]; then git clone {env:repo} operator; fi' {posargs}
tox --workdir operator -c operator -e integration-database-relation

[testenv:integration-osm-mysql]
description = run operator integration tests
skip_install = true
allowlist_externals =
tox
microk8s
bash
commands =
bash -ec 'if ! [ -f charmed-mysql_{env:version}_amd64.rock ]; then rockcraft pack; fi' {posargs}
microk8s ctr image import charmed-mysql_{env:version}_amd64.rock --base-name {env:base-name}
bash -ec 'if ! [ -d operator ]; then git clone {env:repo} operator; fi' {posargs}
tox --workdir operator -c operator -e integration-osm-mysql

[testenv:integration-replication]
description = run operator integration tests
skip_install = true
allowlist_externals =
tox
microk8s
bash
commands =
bash -ec 'if ! [ -f charmed-mysql_{env:version}_amd64.rock ]; then rockcraft pack; fi' {posargs}
microk8s ctr image import charmed-mysql_{env:version}_amd64.rock --base-name {env:base-name}
bash -ec 'if ! [ -d operator ]; then git clone {env:repo} operator; fi' {posargs}
tox --workdir operator -c operator -e integration-replication

[testenv:integration-self-healing]
description = run operator integration tests
skip_install = true
allowlist_externals =
tox
microk8s
bash
commands =
bash -ec 'if ! [ -f charmed-mysql_{env:version}_amd64.rock ]; then rockcraft pack; fi' {posargs}
microk8s ctr image import charmed-mysql_{env:version}_amd64.rock --base-name {env:base-name}
bash -ec 'if ! [ -d operator ]; then git clone {env:repo} operator; fi' {posargs}
tox --workdir operator -c operator -e integration-self-healing

[testenv:integration-tls]
description = run operator integration tests
skip_install = true
allowlist_externals =
tox
microk8s
bash
commands =
bash -ec 'if ! [ -f charmed-mysql_{env:version}_amd64.rock ]; then rockcraft pack; fi' {posargs}
microk8s ctr image import charmed-mysql_{env:version}_amd64.rock --base-name {env:base-name}
bash -ec 'if ! [ -d operator ]; then git clone {env:repo} operator; fi' {posargs}
tox --workdir operator -c operator -e integration-tls

[testenv:integration-backups]
description = run operator integration tests
skip_install = true
allowlist_externals =
tox
microk8s
bash
commands =
bash -ec 'if ! [ -f charmed-mysql_{env:version}_amd64.rock ]; then rockcraft pack; fi' {posargs}
microk8s ctr image import charmed-mysql_{env:version}_amd64.rock --base-name {env:base-name}
bash -ec 'if ! [ -d operator ]; then git clone {env:repo} operator; fi' {posargs}
tox --workdir operator -c operator -e integration-backups