Skip to content

Commit c7b8853

Browse files
Error handling (WIP)
1 parent ee1c69d commit c7b8853

File tree

3 files changed

+50
-9
lines changed

3 files changed

+50
-9
lines changed

.github/workflows/python_test.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,23 @@ jobs:
2525
- name: checkout repo content
2626
uses: actions/checkout@v3
2727
# TODO: debug 'cache not found for input keys dotlocal-Linux-8e1cebf...'
28-
- name: load cached $HOME/.local
29-
uses: actions/cache@v2.1.6
30-
id: cash-money
31-
with:
32-
path: ~/.local
33-
key: dotlocal-${{ runner.os }}-${{ hashFiles('.github/workflows/python_test.yml') }}
28+
# - name: load cached $HOME/.local
29+
# uses: actions/cache@v2.1.6
30+
# id: cash-money
31+
# with:
32+
# path: ~/.local
33+
# key: dotlocal-${{ runner.os }}-${{ hashFiles('.github/workflows/python_test.yml') }}
3434
# - run: echo '${{ steps.cash-money.outputs.cache-hit }}' # true if cache-hit occured on the primary key
35+
# TODO: use `git config --global --add safe.directory` to find working dir (may need to set under checkout step)
3536
- name: set cwd and change to directory
3637
run: |
38+
CWD=$(basename $(git rev-parse --show-toplevel))
3739
BASE_DIR=$(cat BASE_DIR)
3840
echo "BASE_DIR=$BASE_DIR" >> $GITHUB_ENV
39-
cd ${{ env.BASE_DIR }} || unset BASE_DIR; BASE_DIR=$(pwd) && echo "BASE_DIR=$BASE_DIR" >> $GITHUB_ENV
41+
cd ${{ env.BASE_DIR }} || unset BASE_DIR; \
42+
BASE_DIR="$(pwd)/work/${CWD}/${CWD}" && echo "BASE_DIR=$BASE_DIR" >> $GITHUB_ENV; \
43+
cd ${{ env.BASE_DIR }}
44+
# - run: ls -la ${{ env.BASE_DIR }}
4045
- name: Read .tool-versions # dynamic versions
4146
uses: marocchino/tool-versions-action@v1
4247
id: versions
@@ -45,8 +50,8 @@ jobs:
4550
- name: shuffle files
4651
run: |
4752
cat ${{ env.BASE_DIR }}/.tool-versions | awk '/python/ {print $NF}' >> ${{ env.BASE_DIR }}/.python-version
48-
[[ -e "$(pwd)/pyproject.toml" ]] && mv "$(pwd)/pyproject.toml" "$(pwd)/pyproject.toml.bak"
49-
cp "${{ env.BASE_DIR }}/pyproject.toml" $(pwd)/
53+
# [[ -e "$(pwd)/pyproject.toml" ]] && mv "$(pwd)/pyproject.toml" "$(pwd)/pyproject.toml.bak"
54+
# cp "${{ env.BASE_DIR }}/pyproject.toml" $(pwd)/
5055
- name: setup python
5156
uses: actions/setup-python@v4
5257
with:

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,3 +615,11 @@ deactivate
615615
[MongoDB Python Connection | MongoDB](https://www.mongodb.com/languages/python)
616616
617617
[Python MongoDB](https://www.w3schools.com/python/python_mongodb_getstarted.asp)
618+
619+
[Learn GitHub Actions - GitHub Docs](https://docs.github.com/en/actions/learn-github-actions)
620+
621+
[Using scripts to test your code on a runner - GitHub Docs](https://docs.github.com/en/actions/examples/using-scripts-to-test-your-code-on-a-runner)
622+
623+
[Caching dependencies to speed up workflows - GitHub Docs](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows)
624+
625+
[Skipping workflow runs - GitHub Docs](https://docs.github.com/en/actions/managing-workflow-runs/skipping-workflow-runs)

nosql/mongo/docker-compose.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
version: '3'
2+
3+
services:
4+
app:
5+
container_name: mongo-cont
6+
image: docker_python
7+
tty: true # false for `entrypoint` in Dockerfile
8+
stdin_open: true # false for `entrypoint` in Dockerfile
9+
env_file:
10+
- .env
11+
environment:
12+
- MONGODB_CONNSTRING=mongodb://${USER}:${PASS}@mongodb
13+
volumes:
14+
- .:/home/appuser/app
15+
ports:
16+
- 3000:3000
17+
build:
18+
context: ./
19+
dockerfile: ./Dockerfile
20+
21+
mongodb:
22+
image: mongo:5.0
23+
# TODO: debug `error: missing 'MONGO_INITDB_ROOT_...'`
24+
# `docker-compose config` shows both creds
25+
env_file:
26+
# - MONGO_INITDB_ROOT_USERNAME=${USER}
27+
# - MONGO_INITDB_ROOT_PASSWORD=${PASS}
28+
- .env

0 commit comments

Comments
 (0)