Commit b99d42a7 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

docs: add chapter to test TBC scripts in containers

parent dd6418d7
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -2,3 +2,37 @@

This project centralizes, tests, incubates some `to-be-continuous` common stuff (mainly scripts).

## Test TBC scripts in containers

1. run the container (alpine, debian, ~~fedora~~)
    ```bash
    docker run --rm -it --entrypoint /bin/sh --volume $(pwd):/app --workdir /app alpine
    ```
2. in the container
    ```bash
    export XDG_CACHE_HOME=/app/.cache
    set +e

    # test maybe_install_packages
    source tbc_base.sh
    source tbc_maybe_install_packages.sh
    maybe_install_packages wget ca-certificates git

    # test unscope_variables
    source tbc_base.sh
    source tbc_unscope_vars.sh
    export CI_JOB_STAGE=test
    export scoped__TESTVAR1__if__CI_JOB_STAGE__equals__test="stage is 'test'"
    export scoped__TESTVAR2__if__CI_JOB_STAGE__equals__abcde="stage is 'abcde'"
    export scoped__TESTVAR3__if__CI_JOB_STAGE__in__build__test="stage is 'build' or 'test'"
    export scoped__TESTVAR4__if__CI_JOB_STAGE__in__package__package_test="stage is 'package' or 'package-test'"
    export scoped__TESTVAR5__if__CI_JOB_STAGE__startswith__te="stage starts with 'te'" # problème sur Alpine - non sélectionné
    export scoped__TESTVAR6__if__CI_JOB_STAGE__startswith__ab="stage starts with 'ab'"
    export scoped__TESTVAR7__if__CI_JOB_STAGE__endswith__st="stage ends with 'st'"
    export scoped__TESTVAR8__if__CI_JOB_STAGE__endswith__de="stage ends with 'de'"
    export scoped__TESTVAR9__if__CI_JOB_STAGE__contains__es="stage contains 'es'" # problème sur Alpine - tests: unknown operand
    export scoped__TESTVAR10__if__CI_JOB_STAGE__contains__bcd="stage contains 'bcd'"
    unscope_variables

    ...
    ```