From b901585e6130000640eb75946e5a0bbb28b15b76 Mon Sep 17 00:00:00 2001 From: giginet Date: Thu, 21 Jul 2022 21:53:43 +0900 Subject: [PATCH 1/4] Introduce GitHub Action --- .github/workflows/ci.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..d62ea104 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: Pokédex CI + +on: + push: + branches: ["master-pokeapi"] + pull_request: + branches: ["master-pokeapi"] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e . + - name: Run Setup + run: | + pokedex setup + - name: Dump DB + run: | + pokedex dump -l all From 6b9eb25965988589d92c61ed580cc1b7a5bfbc37 Mon Sep 17 00:00:00 2001 From: giginet Date: Fri, 22 Jul 2022 01:57:54 +0900 Subject: [PATCH 2/4] Add tests for Docker Containers --- .github/workflows/ci.yml | 21 ++++++++++++++++++++- bin/docker-pokedex | 3 ++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d62ea104..7bbe2e7e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,26 @@ on: branches: ["master-pokeapi"] jobs: - build: + Docker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup + continue-on-error: true + run: | + docker run -it --rm \ + --name "pokedex-$(date +%Y%m%d-%H%M%S)" \ + --mount type=bind,source="${curr_dir}/pokedex/data",target=/app/pokedex/data \ + veekun/pokedex setup -v + - name: Dump Pokédex + continue-on-error: true + run: | + bin/docker-pokedex dump -l all + - name: Print log + run: | + cat bin/docker-pokedex.log + + Python: runs-on: ubuntu-latest strategy: matrix: diff --git a/bin/docker-pokedex b/bin/docker-pokedex index 76db50ae..fd9047cd 100755 --- a/bin/docker-pokedex +++ b/bin/docker-pokedex @@ -14,7 +14,8 @@ if [[ "${1}" = "rebuild" ]] || [[ ! -f "${log_file}" ]]; then fi docker run -it --rm \ + --verbose \ -e TERM=xterm-256color \ --name "pokedex-$(date +%Y%m%d-%H%M%S)" \ --mount type=bind,source="${curr_dir}/pokedex/data",target=/app/pokedex/data \ - veekun/pokedex "${@}" \ No newline at end of file + veekun/pokedex "${@}" From 5ce3a6cdddf176160f1156bf77e0ac710bd2db60 Mon Sep 17 00:00:00 2001 From: giginet Date: Fri, 22 Jul 2022 02:30:11 +0900 Subject: [PATCH 3/4] Disable TTY on CI --- .github/workflows/ci.yml | 11 ++++------- bin/docker-pokedex | 20 ++++++++++++++------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7bbe2e7e..62f6b70d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,9 @@ on: pull_request: branches: ["master-pokeapi"] +env: + ENABLE_TTY: 0 + jobs: Docker: runs-on: ubuntu-latest @@ -14,17 +17,11 @@ jobs: - name: Setup continue-on-error: true run: | - docker run -it --rm \ - --name "pokedex-$(date +%Y%m%d-%H%M%S)" \ - --mount type=bind,source="${curr_dir}/pokedex/data",target=/app/pokedex/data \ - veekun/pokedex setup -v + bin/docker-pokedex setup -v - name: Dump Pokédex continue-on-error: true run: | bin/docker-pokedex dump -l all - - name: Print log - run: | - cat bin/docker-pokedex.log Python: runs-on: ubuntu-latest diff --git a/bin/docker-pokedex b/bin/docker-pokedex index fd9047cd..5113d7b6 100755 --- a/bin/docker-pokedex +++ b/bin/docker-pokedex @@ -2,6 +2,7 @@ curr_dir="$(pwd)" log_file="${curr_dir}/bin/docker-pokedex.log" +ENABLE_TTY=${ENABLE_TTY:-1} if [[ "${1}" = "rebuild" ]] || [[ ! -f "${log_file}" ]]; then docker build --rm -t veekun/pokedex ${curr_dir} @@ -13,9 +14,16 @@ if [[ "${1}" = "rebuild" ]] || [[ ! -f "${log_file}" ]]; then fi; fi -docker run -it --rm \ - --verbose \ - -e TERM=xterm-256color \ - --name "pokedex-$(date +%Y%m%d-%H%M%S)" \ - --mount type=bind,source="${curr_dir}/pokedex/data",target=/app/pokedex/data \ - veekun/pokedex "${@}" +options=( + run + --rm + -e TERM=xterm-256color + --name "pokedex-$(date +%Y%m%d-%H%M%S)" + --mount type=bind,source="${curr_dir}/pokedex/data",target=/app/pokedex/data \ + veekun/pokedex "${@}" +) +if [ "$ENABLE_TTY" -ne 0 ]; then + options+=(-it) +fi + +docker ${options[@]} From 2810724f85784ad483e5cf59c17a90e3a3294120 Mon Sep 17 00:00:00 2001 From: giginet Date: Fri, 22 Jul 2022 03:03:13 +0900 Subject: [PATCH 4/4] Disable continue-on-error --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 62f6b70d..302ff53d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,11 +15,9 @@ jobs: steps: - uses: actions/checkout@v3 - name: Setup - continue-on-error: true run: | bin/docker-pokedex setup -v - name: Dump Pokédex - continue-on-error: true run: | bin/docker-pokedex dump -l all