Skip to content

Commit

Permalink
Merge pull request edgehog-device-manager#613 from noaccOS/feat/azure
Browse files Browse the repository at this point in the history
feat: azure support
  • Loading branch information
davidebriani authored Dec 19, 2024
2 parents ad4cb42 + ed8f2f7 commit 6d3e198
Show file tree
Hide file tree
Showing 10 changed files with 572 additions and 61 deletions.
157 changes: 157 additions & 0 deletions .github/workflows/backend-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,163 @@ jobs:
if: matrix.postgres != env.postgres_version_uploading_to_coveralls
run: mix test

integration-minio:
name: Integration tests using MinIO
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
minio:
image: bitnami/minio:latest
env:
MINIO_ROOT_USER: "minioadmin"
MINIO_ROOT_PASSWORD: "minioadmin"
ports:
- 9000:9000
options: >-
--name minio
--health-interval 10s
--health-timeout 5s
--health-retries 5
--health-cmd "curl http://localhost:9000/minio/health/live"
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
show-progress: false

- name: Bucket setup
run: |
wget https://dl.min.io/client/mc/release/linux-amd64/mc
chmod +x ./mc
./mc alias set minio http://localhost:9000 minioadmin minioadmin;
./mc mb minio/edgehog;
./mc anonymous set download minio/edgehog;
- name: Install OTP and Elixir
uses: erlef/setup-beam@v1
id: beam
with:
version-file: .tool-versions
version-type: strict

- name: Cache dependencies
id: cache-deps
uses: actions/cache@v3
with:
path: |
backend/deps
backend/_build
key: "${{ runner.os }}-\
otp-${{ steps.beam.outputs.otp-version }}-\
elixir-${{ steps.beam.outputs.elixir-version }}-\
${{ hashFiles('backend/mix.lock') }}"

- name: Install and compile dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
mix deps.get --only test
mix deps.compile
- name: Test
env:
STORAGE_TYPE: s3
S3_ACCESS_KEY_ID: minioadmin
S3_SECRET_ACCESS_KEY: minioadmin
S3_REGION: local
S3_SCHEME: http://
S3_HOST: localhost
S3_PORT: 9000
S3_BUCKET: edgehog
S3_ASSET_HOST: http://localhost:9000/edgehog
run: mix test --only integration_storage

integration-azurite:
name: Integration tests using Azurite
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
azurite:
image: mcr.microsoft.com/azure-storage/azurite
ports:
- "10000:10000"
- "10001:10001"
- "10002:10002"
options: >-
--health-cmd "nc -z 127.0.0.1 10000"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
show-progress: false

- name: Storage setup
env:
AZURE_STORAGE_CONNECTION_STRING: "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;"
run: |
# install az-cli
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
# setup container
az storage container create --name edgehog --connection-string $AZURE_STORAGE_CONNECTION_STRING
az storage container set-permission --name edgehog --public-access blob --connection-string $AZURE_STORAGE_CONNECTION_STRING
- name: Install OTP and Elixir
uses: erlef/setup-beam@v1
id: beam
with:
version-file: .tool-versions
version-type: strict

- name: Cache dependencies
id: cache-deps
uses: actions/cache@v3
with:
path: |
backend/deps
backend/_build
key: "${{ runner.os }}-\
otp-${{ steps.beam.outputs.otp-version }}-\
elixir-${{ steps.beam.outputs.elixir-version }}-\
${{ hashFiles('backend/mix.lock') }}"

- name: Install and compile dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
mix deps.get --only test
mix deps.compile
- name: Test
env:
STORAGE_TYPE: azure
AZURE_BLOB_ENDPOINT: "http://localhost:10000/devstoreaccount1"
AZURE_CONTAINER: "edgehog"
AZURE_STORAGE_ACCOUNT_KEY: "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
AZURE_STORAGE_ACCOUNT_NAME: "devstoreaccount1"
run: mix test --only integration_storage

build-docker-image:
name: Build Docker image
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.10] - Unreleased
### Added
- Managed OTA operations expose the update target that created them in graphql ([#356](https://github.com/edgehog-device-manager/edgehog/issues/356).
- Support for using Azure Storage as the persistence layer for asset uploads ([#233](https://github.com/edgehog-device-manager/edgehog/issues/233)).

## [0.9.3] - Unreleased
### Fixed
Expand Down
6 changes: 6 additions & 0 deletions backend/config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@

import Config

config :azurex, Azurex.Blob.Config,
api_url: "http://localhost:10000/devstoreaccount1",
default_container: "edgehog",
storage_account_name: "devstoreaccount1",
storage_account_key: "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="

# Configure your database
config :edgehog, Edgehog.Repo,
username: "postgres",
Expand Down
Loading

0 comments on commit 6d3e198

Please sign in to comment.