|
17 | 17 | permissions:
|
18 | 18 | id-token: write # needed for signing the images with GitHub OIDC Token
|
19 | 19 | packages: write # needed for publishing packages to GHCR
|
20 |
| - env: |
21 |
| - TEST_TAG: vectorim/element-web:test |
22 | 20 | steps:
|
23 | 21 | - uses: actions/checkout@v4
|
24 | 22 | with:
|
@@ -52,26 +50,41 @@ jobs:
|
52 | 50 | password: ${{ secrets.GITHUB_TOKEN }}
|
53 | 51 |
|
54 | 52 | - name: Build and load
|
| 53 | + id: test-build |
55 | 54 | uses: docker/build-push-action@ca877d9245402d1537745e0e356eab47c3520991 # v6
|
56 | 55 | with:
|
57 | 56 | context: .
|
58 | 57 | load: true
|
59 |
| - tags: ${{ env.TEST_TAG }} |
60 | 58 |
|
61 | 59 | - name: Test the image
|
| 60 | + env: |
| 61 | + IMAGEID: ${{ steps.test-build.outputs.imageid }} |
62 | 62 | run: |
|
| 63 | + set -x |
| 64 | +
|
63 | 65 | # Make a fake module to test the image
|
64 | 66 | MODULE_PATH="modules/module_name/index.js"
|
65 | 67 | mkdir -p $(dirname $MODULE_PATH)
|
66 | 68 | echo 'alert("Testing");' > $MODULE_PATH
|
67 | 69 |
|
68 | 70 | # Spin up a container of the image
|
69 |
| - CONTAINER_ID=$(docker run --rm -dp 80:80 -v $(pwd)/modules:/tmp/element-web-modules ${{ env.TEST_TAG }}) |
| 71 | + ELEMENT_WEB_PORT=8181 |
| 72 | + CONTAINER_ID=$( |
| 73 | + docker run \ |
| 74 | + --rm \ |
| 75 | + -e "ELEMENT_WEB_PORT=$ELEMENT_WEB_PORT" \ |
| 76 | + -dp "$ELEMENT_WEB_PORT:$ELEMENT_WEB_PORT" \ |
| 77 | + -v $(pwd)/modules:/tmp/element-web-modules \ |
| 78 | + "$IMAGEID" \ |
| 79 | + ) |
70 | 80 |
|
71 | 81 | # Run some smoke tests
|
72 |
| - wget --retry-connrefused --tries=5 -q --wait=3 --spider http://localhost:80/modules/module_name/index.js |
73 |
| - MODULE_1=$(curl http://localhost:80/config.json | jq -r .modules[0]) |
74 |
| - test "$MODULE_1" = "/${MODULE_PATH}" |
| 82 | + wget --retry-connrefused --tries=5 -q --wait=3 --spider "http://localhost:$ELEMENT_WEB_PORT/modules/module_name/index.js" |
| 83 | + MODULE_0=$(curl "http://localhost:$ELEMENT_WEB_PORT/config.json" | jq -r .modules[0]) |
| 84 | + test "$MODULE_0" = "/${MODULE_PATH}" |
| 85 | +
|
| 86 | + # Check healthcheck |
| 87 | + test "$(docker inspect -f {{.State.Running}} $CONTAINER_ID)" == "true" |
75 | 88 |
|
76 | 89 | # Clean up
|
77 | 90 | docker stop "$CONTAINER_ID"
|
|
0 commit comments