Skip to content

Commit

Permalink
chore: Creating reproducible devcontainer environment
Browse files Browse the repository at this point in the history
  • Loading branch information
steilerDev committed Feb 11, 2025
1 parent a07170d commit 0f0f44d
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 33 deletions.
33 changes: 20 additions & 13 deletions .devcontainer/devcontainer.json → .devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// https://github.com/microsoft/vscode-dev-containers/tree/v0.117.1/containers/typescript-node-12
{
"name": "icloud-photos-sync",
"image": "mcr.microsoft.com/devcontainers/base:bullseye",
"image": "mcr.microsoft.com/devcontainers/base:bookworm",
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"username": "vscode",
Expand All @@ -18,7 +18,7 @@
"version": "latest"
},
"ghcr.io/devcontainers/features/node:1": {
"version": "18.18.0"
"version": "22.13.1"
},
"ghcr.io/devcontainers/features/python:1": {
"version": "3.9"
Expand All @@ -42,24 +42,31 @@
}
},

"runArgs": ["--env-file","secrets/test.env"],
"containerEnv": {
"NODE_NO_WARNINGS": "1",
"DATA_DIR": "${containerWorkspaceFolder}/app-data-dir/"
"DATA_DIR": "/opt/test-data-dir/"
},

"secrets": {
"APPLE_ID_USER": {
"description": "Your Apple ID username"
"mounts": [
{
"source": "test-data-dir",
"target": "/opt/test-data-dir",
"type": "volume"
},
"APPLE_ID_PWD": {
"description": "Your Apple ID password"
{
"source": "prod-data-dir",
"target": "/opt/prod-data-dir",
"type": "volume"
},
"TRUST_TOKEN": {
"description": "Your trust token"
}
},
{
"source": "adp-data-dir",
"target": "/opt/adp-data-dir",
"type": "volume"
},
],

"postCreateCommand": "(cd app/ && npm install) && (cd docs/ && pip install -r requirements.txt)",
"postCreateCommand": "(cd app/ && npm install) && (cd docs/ && pip install -r requirements.txt) && sudo chown -R 1000:1000 /opt",

"remoteUser": "vscode"
}
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ updates:
time: "09:00"
timezone: "Europe/Berlin"

# Maintain dependencies for devcontainer
- package-ecosystem: "devcontainers" # See documentation for possible values
labels: [ ]
directory: "/"
target-branch: "dev"
open-pull-requests-limit: 20
commit-message:
prefix: "chore: [dev] "
schedule:
interval: "weekly"
day: "saturday"
time: "09:00"
timezone: "Europe/Berlin"

# Maintain dependencies for npm
- package-ecosystem: "npm"
labels: [ ]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/artifacts_test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: 'Artifacts: Test'
# This workflow will test the requested artifacts
# In order to run E2E and API tests, an Apple ID test user is required. The self-hosted runner is expected to have those set in the `.env` file located in the runner's directory.

on:
workflow_call:
Expand Down
3 changes: 3 additions & 0 deletions .vscode/icloud-photos-sync.cspell
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dawidd6
DBRP
dedup
deFEyox97ecdknADe0xP4YzIDDKf
devcontainers
devmasx
Disp
dockerhub
Expand Down Expand Up @@ -115,10 +116,12 @@ upterm
uptermd
viktorstrate
vivaxy
vscodevim
Vvye
vyas
WEBAUTH
webmproject
webservices
whois
xyz
Yons
10 changes: 5 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
],
"preLaunchTask": "Build App",
"program": "${workspaceFolder}/app/src/main.ts",
"args": ["sync"],
"args": ["token"],
"outFiles": [
"${workspaceFolder}/app/build/out/**/*.js",
],
"env": {
"NODE_NO_WARNINGS": "1"
},
"envFile": "${workspaceFolder}/.vscode/adp-test.env"
"envFile": "${workspaceFolder}/secrets/adp.env"
}, {
"name": "Run API Tests",
"type": "node",
Expand All @@ -37,7 +37,7 @@
"env": {
"NODE_NO_WARNINGS": "1"
},
"envFile": "${workspaceFolder}/.vscode/api-test.env"
"envFile": "${workspaceFolder}/secrets/test.env"
}, {
"name": "Run All Tests",
"type": "node",
Expand All @@ -50,7 +50,7 @@
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"cwd": "${workspaceFolder}/app",
"envFile": "${workspaceFolder}/.vscode/api-test.env",
"envFile": "${workspaceFolder}/secrets/test.env",
"env": {
"NODE_NO_WARNINGS": "1"
},
Expand All @@ -73,7 +73,7 @@
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"cwd": "${workspaceFolder}/app",
"envFile": "${workspaceFolder}/.vscode/api-test.env"
"envFile": "${workspaceFolder}/.vscode/test.env"
},
]
}
8 changes: 4 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@
"githubPullRequests.queries": [
{
"label": "Dependabot",
"query": "is:open is:pr author:app/dependabot"
"query": "repo:${owner}/${repository} is:open is:pr author:app/dependabot"
},
{
"label": "Created By Me",
"query": "is:open author:${user}"
"query": "repo:${owner}/${repository} is:open author:${user}"
},
{
"label": "Released",
"query": "is:open is:pr label:status(released)"
"query": "repo:${owner}/${repository} is:open is:pr label:status(released)"
},
{
"label": "Truly Open",
"query": "is:open is:pr -label:status(released) -label:status(previewed)"
"query": "repo:${owner}/${repository} is:open is:pr -label:status(released) -label:status(previewed)"
}
],
"githubPullRequests.notifications": "pullRequests",
Expand Down
2 changes: 1 addition & 1 deletion app/test/api/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe(`API E2E Tests`, () => {
await expect(icloud.authenticate()).rejects.toThrow(/^Username\/Password does not seem to match$/);
});

test(`Success - Legacy Login`, async () => {
test.only(`Success - Legacy Login`, async () => {
instances.manager._resources.legacyLogin = true;
const icloud = new iCloud();
await expect(icloud.authenticate()).resolves.not.toThrow();
Expand Down
12 changes: 2 additions & 10 deletions docs/src/dev/dev-environment.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Development Environment

A reproducible development environment is available through [DevContainers](https://containers.dev/). Please make sure to populate the environment files in the `secrets/` to use all features.

## IDE

This tool is developed using [coder's code server](https://github.com/coder/code-server) and a local installation of VSCode.
Expand Down Expand Up @@ -39,13 +41,3 @@ The following extensions are used during development and are configured as part

## Running in a development environment

This repository defines VSCode tasks and debug configurations. The latter references the `test.env` file from the `.vscode` directory in order to access secrets while executing. Alternatively the basic authentication credentials (username, password and trust token) could be exported.

```
APPLE_ID_USER=<test-user>
APPLE_ID_PWD=<test-password>
TRUST_TOKEN=<test-trust-token>
ENABLE_CRASH_REPORTING=true
FORCE=true
DATA_DIR=<projectFolder>/app-data-dir/
```
1 change: 1 addition & 0 deletions secrets/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.env
8 changes: 8 additions & 0 deletions secrets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This folder is meant for development purposes and contains environment files containing secrets.

The following files are expected, in order to test and develop this application:
- `test.env` - containing credentials for executing API and E2E tests
- `adp.env` - (*optional*) containing credentials for executing API and E2E tests against and ADP account.
- `prod.env` - (*optional*) containing credentials for a production account used for development purposes.

These environment files are read by VSCode tasks, as well as the devcontainer setup.
8 changes: 8 additions & 0 deletions secrets/adp.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
APPLE_ID_USER=
APPLE_ID_PWD=
DATA_DIR=/opt/adp-data-dir/
ENABLE_CRASH_REPORTING=true
ENABLE_NETWORK_CAPTURE=true
EXPORT_METRICS=true
LOG_LEVEL=debug
FORCE=true
8 changes: 8 additions & 0 deletions secrets/prod.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
APPLE_ID_USER=
APPLE_ID_PWD=
DATA_DIR=/opt/prod-data-dir/
ENABLE_CRASH_REPORTING=true
ENABLE_NETWORK_CAPTURE=true
EXPORT_METRICS=true
LOG_LEVEL=debug
FORCE=true
3 changes: 3 additions & 0 deletions secrets/test.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
TEST_APPLE_ID_USER=
TEST_APPLE_ID_PWD=
TEST_TRUST_TOKEN=HSARMTKNSRVXWFlajFMlr2wBE+17pwWTjKKG0AwcN0gG81YRtIMs7QNNgXDqRb8ntIsP6CZ0hXAYwuax5I2b849WwXPbudpAR9OLYUez3BHEgZBBnVqUqQPabCrhPV4FyGLdNf7jhWy1CGdLCYAtQeNnDfuJIq7XQgvMlXLBNu1mZwnRtM9Dmz+M3wK9uie3ljTcfUDapYkUq3G01wXijMmX2h4XlFLa/EyjFAWMphw=SRVX

0 comments on commit 0f0f44d

Please sign in to comment.