diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..302ff53d9 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,45 @@ +name: Pokédex CI + +on: + push: + branches: ["master-pokeapi"] + pull_request: + branches: ["master-pokeapi"] + +env: + ENABLE_TTY: 0 + +jobs: + Docker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup + run: | + bin/docker-pokedex setup -v + - name: Dump Pokédex + run: | + bin/docker-pokedex dump -l all + + Python: + 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 diff --git a/bin/docker-pokedex b/bin/docker-pokedex index 76db50ae5..5113d7b68 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,8 +14,16 @@ if [[ "${1}" = "rebuild" ]] || [[ ! -f "${log_file}" ]]; then fi; fi -docker run -it --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 "${@}" \ No newline at end of file +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[@]}