Skip to content

Commit

Permalink
Bugfix release: 2.1.1 / 2023-03-29
Browse files Browse the repository at this point in the history
- Copied `package-versions.json` to the built image. Added `jq` to the
  supported tools.

- Rather than committing `pgtap.tar`, we will be committing the generated
  files for easier comparison.

- Changed the `run` script to pull from ghcr.io by default instead of Docker
  Hub and other `run` script improvements.

- Fixed a bug with `do_pgtap` version detection depending on the
  configuration of the local `.psqlrc`. It now explicitly does not load
  a `.psqlrc` file.

- Changed `scripts/do_version` (version reporting) to properly report the
  pgtap version, including the commit hashref if included.

Also added a test to the test build workflow.
  • Loading branch information
halostatue committed Mar 29, 2023
1 parent 4921a9c commit b2a4b8b
Show file tree
Hide file tree
Showing 24 changed files with 87,086 additions and 76 deletions.
31 changes: 6 additions & 25 deletions .github/workflows/build-test-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,6 @@ jobs:
steps:
- uses: actions/checkout@v3

- id: meta
uses: docker/metadata-action@507c2f2dc502c992ad446e3d7a5dfbe311567a96 # v4.3.0
with:
images: |
kineticcafe/sqitch-pgtap
ghcr.io/kineticcafe/sqitch-pgtap
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 # v2.1.0
- uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c # v2.5.0

- id: package-versions
Expand All @@ -39,15 +22,13 @@ jobs:
with:
context: .
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
load: true
tags: kineticcafe/sqitch-pgtap:test
build-args: |
PG_PROVE_VERSION=${{ fromJSON(steps.package-versions.outputs.data).pg_prove.version }}
PGTAP_VERSION=${{ fromJSON(steps.package-versions.outputs.data).pgtap.version }}
SQITCH_VERSION=${{ fromJSON(steps.package-versions.outputs.data).sqitch.version }}
platforms: |
linux/amd64
linux/arm64
linux/arm/v7
cache-from: type=gha
cache-to: type=gha,mode=max
- run: ./run version
env:
IMAGE: kineticcafe/sqitch-pgtap:test
19 changes: 18 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
# docker-sqitch-pgtap Changelog
# kineticcafe/sqitch-pgtap Changelog

## 2.1.1 / 2023-03-29

- Copied `package-versions.json` to the built image. Added `jq` to the supported
tools.

- Rather than committing `pgtap.tar`, we will be committing the generated files
for easier comparison.

- Changed the `run` script to pull from ghcr.io by default instead of Docker
Hub and other `run` script improvements.

- Fixed a bug with `do_pgtap` version detection depending on the configuration
of the local `.psqlrc`. It now explicitly does not load a `.psqlrc` file.

- Changed `scripts/do_version` (version reporting) to properly report the pgtap
version, including the commit hashref if included.

## 2.1.0 / 2023-03-26

Expand Down
25 changes: 14 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
FROM alpine:3.17 AS build-pgtap

COPY pgtap.tar /tmp

RUN tar xf /tmp/pgtap.tar

FROM alpine:3.17

ARG PG_PROVE_VERSION
Expand All @@ -12,15 +6,17 @@ ARG SQITCH_VERSION

ENV __DOCKERFILE_VERSION__=2.1.0

RUN apk add --no-cache --update \
RUN apk update \
&& apk add --no-cache --update \
build-base \
curl \
wget \
make \
perl-dev \
postgresql-dev \
make \
wget \
&& apk add --no-cache --update \
bash \
jq \
less \
nano \
openssl \
Expand All @@ -35,11 +31,18 @@ RUN apk add --no-cache --update \
&& adduser --disabled-password sqitch \
&& mkdir -p /opt /home/sqitch/bin \
&& echo $__DOCKERFILE_VERSION__ > /home/sqitch/VERSION \
&& apk del curl wget postgresql-dev build-base make perl-dev \
&& apk del \
build-base \
curl \
make \
perl-dev \
postgresql-dev \
wget \
&& rm -rf /var/cache/apk/* /tmp/* /root/.cpanm

COPY --from=build-pgtap /opt/pgtap /opt/pgtap
COPY opt/pgtap /opt/pgtap/
COPY scripts/* /home/sqitch/bin/
COPY package-versions.json /home/sqitch/
RUN chmod +x /home/sqitch/bin/* \
&& chown -R sqitch:sqitch /home

Expand Down
2 changes: 2 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ get-pgtap:
docker container cp --quiet builder:/opt/pgtap.tar "{{ justfile_directory() }}"
docker container rm builder
docker image rm build-pgtap:latest
tar xf pgtap.tar

rm -rf {{ justfile_directory() }}/build/pgtap/pgtap-"{{ pgtap_version }}" \
{{ justfile_directory() }}/build/pgtap/pgtap-"{{ pgtap_version }}".zip \
{{ justfile_directory() }}/pgtap.tar
17 changes: 11 additions & 6 deletions LICENCE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The MIT License (MIT)

Copyright © 2021 Kinetic Cafe
Copyright © 2021–2023 Kinetic Commerce

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the \"Software\"), to deal in
Expand All @@ -24,12 +24,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This repository includes instructions to build a Docker container that
explicitly incorporates:

- [Alpine Linux]: GNU GPL v2
- [sqitch]: [MIT][sqitch-mit]
- [pgtap]: [Modified MIT][pgtap-mit]
- [Alpine Linux][]: GNU GPL v2
- [sqitch][]: [MIT][sqitch-mit]
- [pgTAP][]: [Modified MIT][pgtap-mit]
- [TAP::Parser::SourceHandler::pgTAP][theory/tap-parser-sourcehandler-pgtap]:
[Perl][pgtap-perl]
- [nano]: GNU GPL v3
- [nano][]: GNU GPL v3
- [jq][]: [Modified MIT + CC BY 3.0][jq-mit]

This Docker container was developed in part from examples provided by:

Expand All @@ -38,7 +39,10 @@ This Docker container was developed in part from examples provided by:
- [LREN-CHUV/docker-pgtap]: [Apache 2.0][docker-pgtap-apache]
- [disaykin/pgtap-docker-image]: [BSD 3-Clause][pgtap-docker-image-bsd]

The scripts were developed based on scripts in the above repositories.
The scripts were developed based on scripts in the above repositories but have
since diverged extensively. For build performance purposes, version-specific
copies of the [pgTAP][] code are kept in `opt/pgtap` and are covered under the
original [pgTAP licence][pgtap-mit].

[disaykin/pgtap-docker-image]: https://github.com/disaykin/pgtap-docker-image
[docker-sqitch-mit]: https://github.com/sqitchers/docker-sqitch/blob/main/LICENSE.md
Expand All @@ -54,3 +58,4 @@ The scripts were developed based on scripts in the above repositories.
[nano]: https://www.nano-editor.org
[docker-pgtap-apache]: https://github.com/LREN-CHUV/docker-pgtap/blob/master/LICENSE
[pgtap-docker-image-bsd]: https://github.com/disaykin/pgtap-docker-image/blob/master/LICENSE
[jq-mit]: https://github.com/stedolan/jq/blob/master/COPYING
40 changes: 22 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,43 @@
# Sqitch & pgTAP in Docker
# [ghcr.io/]kineticcafe/sqitch-pgtap: Sqitch/PostgreSQL & pgTAP in Docker

This is a simple Docker container that contains [sqitch][], [pgTAP][], and
[`pg_prove`][]. It has been created so that it's easier to work with `sqitch`
and `pg_prove`/`pgTAP` without going through the effort of installing them on
various systems.
[`pg_prove`][] for use with PostgreSQL. It has been created so that it's easier
to work with `sqitch` and `pg_prove`/`pgTAP` without going through the effort of
installing them on various systems.

The image is based on Alpine (3.17) and does not include a PostgreSQL server;
instead, it is expected that all values will be provided through environment
variables or on the command-line.

This version of the container includes:

- pgTAP 1.2.1 (via git, as 1.2.1 has not been released)
- pgTAP 1.2.1 (via git at `56c591fc3bf6b2dba49e15739625916d49e3fc27`)
- Support for PostgreSQL 9.6, 10, 11, 12, 13, 14, and 15
- pg_prove 3.36
- Sqitch 1.3.1

The version of pgTAP is installed and uninstalled as needed; unit test files
must _not_ `CREATE EXTENSION pgtap`.
_must not_ `CREATE EXTENSION pgtap`.

These images can also be pulled from the GitHub Container Registry at
ghcr.io/kineticcafe/sqitch-pgtap
These images can be pulled either from Docker Hub
(`kineticcafe/sqitch-pgtap:2.1`) or the GitHub Container Registry
(`ghcr.io/kineticcafe/sqitch-pgtap:2.1`).

## `run` script Commands

The `run` script is recommended for running everything as it manages environment
variable configuration for each run.
variable configuration for each run. The `run` script will pull from
`ghcr.io/kineticcafe/sqitch-pgtap:2.1` by default; this can be overridden by
using `$IMAGE`:

```console
$ IMAGE=kineticcafe/sqitch-pgtap:latest ./run version
[gchr.io/]kineticcafe/sqitch-pgtap:2.1.0

sqitch (App::Sqitch) v1.3.1
pgtap 1.2.1 (56c591fc3bf6b2dba49e15739625916d49e3fc27)
pg_prove 3.36
```

### Core commands

Expand Down Expand Up @@ -63,21 +75,13 @@ variable configuration for each run.
### Extra commands

- `sh`: Start a shell in the image
- `jq`: Runs jq
- `nano`: Runs nano
- `show-targets`: Shows configured sqitch targets
- `show-default-target`: Shows the configured default target
- `show-default-dbname`: Shows the configured default target database name
- `pgtap-tests`: Runs `pgtap test test/*.sql` for the default database

## Sources

This image is based loosely on the Docker images in:

- [theory/tap-parser-sourcehandler-pgtap][]
- [LREN-CHUV/docker-pgtap][]
- [docker-sqitch][]
- [disaykin/pgtap-docker-image][]

[`pg_prove`]: https://pgtap.org/pg_prove.html
[disaykin/pgtap-docker-image]: https://github.com/disaykin/pgtap-docker-image
[docker-sqitch]: https://github.com/sqitchers/docker-sqitch
Expand Down
Loading

0 comments on commit b2a4b8b

Please sign in to comment.