mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-12-25 19:21:08 +00:00
ci: Remove Docker test environment from CI (#806)
This commit is contained in:
parent
45e6b3e052
commit
09fe0afc14
@ -1 +0,0 @@
|
||||
target/
|
18
.github/workflows/workflow.yml
vendored
18
.github/workflows/workflow.yml
vendored
@ -152,24 +152,6 @@ jobs:
|
||||
command: test
|
||||
args: -- -Z unstable-options --include-ignored
|
||||
|
||||
# Run the tests in the Docker image
|
||||
docker_test:
|
||||
name: Test in Docker
|
||||
needs: [cargo_check]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Pull the pre-built Docker image
|
||||
run: docker pull starshipcommand/starship-test
|
||||
- name: Fix file permissions
|
||||
run: chmod -R a+w .
|
||||
- name: Build the Docker image
|
||||
run:
|
||||
docker build -f tests/Dockerfile --tag starshipcommand/starship-test --cache-from
|
||||
starshipcommand/starship-test .
|
||||
- name: Run tests in Docker
|
||||
run: docker run --rm -v $(pwd):/src/starship starshipcommand/starship-test
|
||||
|
||||
# Publish starship to Crates.io
|
||||
cargo_publish:
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
|
@ -61,8 +61,8 @@ cargo fmt
|
||||
|
||||
Testing is critical to making sure starship works as intended on systems big and small. Starship interfaces with many applications and system APIs when generating the prompt, so there's a lot of room for bugs to slip in.
|
||||
|
||||
Unit tests and a subset of acceptance tests can be run with `cargo test`.
|
||||
The full acceptance test suite can be run in a Docker container with the included [`./acceptance_test`](acceptance_test) script.
|
||||
Unit tests and a subset of integration tests can be run with `cargo test`.
|
||||
The full integration test suite is run on GitHub as part of our GitHub Actions continuous integration.
|
||||
|
||||
### Unit Testing
|
||||
|
||||
@ -72,24 +72,13 @@ Unit tests should be fully isolated, only testing a given function's expected ou
|
||||
|
||||
The previous point should be emphasized: even seemingly innocuous ideas like "if we can see the directory, we can read it" or "nobody will have their home directory be a git repo" have bitten us in the past. Having even a single test fail can completely break installation on some platforms, so be careful with tests!
|
||||
|
||||
### Acceptance Testing
|
||||
### Integration Testing
|
||||
|
||||
Acceptance tests are located in the [`tests/`](tests) directory and are also written using the built-in Rust testing library.
|
||||
Integration tests are located in the [`tests/`](tests) directory and are also written using the built-in Rust testing library.
|
||||
|
||||
Acceptance tests should test full modules or the entire prompt. All acceptance tests expecting the testing environment to have preexisting state or making permanent changes to the filesystem should have the `#[ignore]` attribute. All tests that don't depend on any preexisting state will be run alongside the unit tests with `cargo test`.
|
||||
Integration tests should test full modules or the entire prompt. All integration tests that expect the testing environment to have pre-existing state or tests that make permanent changes to the filesystem should have the `#[ignore]` attribute added to them. All tests that don't depend on any preexisting state will be run alongside the unit tests with `cargo test`.
|
||||
|
||||
Acceptance tests require Docker to be installed, as they are run inside a Docker container. This can be done as described in the official [documentation](https://docs.docker.com/install/). The acceptance tests can then be executed by running the included [`./acceptance_test`](acceptance_test) script. It might be necessary to run [`./acceptance_test`](acceptance_test) with `sudo` if your user is not part of the `docker` group.
|
||||
|
||||
|
||||
For tests that depend on having preexisting state, whatever needed state will have to be added to the project's Dockerfile ([`tests/Dockerfile`](tests/Dockerfile)) as well as the project's Azure Pipelines configuration ([`azure-pipelines.yml`](azure-pipelines.yml)).
|
||||
|
||||
The reason for having _both_ the Dockerfile as well as the Azure Pipelines configuration is in order to allow acceptance tests to be run on your local development environment via Docker, while also running our test suite on all supported OSes (Windows, Mac, Linux) on Azure Pipelines.
|
||||
|
||||
### Benchmarking
|
||||
|
||||
Benchmarks are located in the [`benches/`](benches) directory and are written using the [Criterion](https://crates.io/crates/criterion) library.
|
||||
|
||||
For the time being, benchmarks aren't actively used, but we plan to integrate benchmark comparison reporting into our CI pipeline in the near future. For the time being, they can be manually run with `cargo bench`.
|
||||
For tests that depend on having preexisting state, whatever needed state will have to be added to the project's GitHub Actions workflow file([`.github/workflows/workflow.yml`](.github/workflows/workflow.yml)).
|
||||
|
||||
## Running the Documentation Website Locally
|
||||
|
||||
|
@ -1,16 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
if ! (docker --version); then
|
||||
printf 'Docker is required to run the starship acceptance tests.\n'
|
||||
printf 'Please download and install Docker in order to run these tests locally.\n'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf 'Building test docker image:\n'
|
||||
docker build -f tests/Dockerfile \
|
||||
--tag starshipcommand/starship-test \
|
||||
--cache-from starshipcommand/starship-test \
|
||||
.
|
||||
|
||||
printf 'Running test suite:\n'
|
||||
docker run --rm -v $(pwd):/src/starship --security-opt="label=disable" starshipcommand/starship-test
|
101
tests/Dockerfile
101
tests/Dockerfile
@ -1,101 +0,0 @@
|
||||
FROM rust
|
||||
|
||||
# Create /src as root
|
||||
RUN mkdir /src && chmod -R a+w /src
|
||||
|
||||
# Create non-root user
|
||||
RUN useradd -ms /bin/bash nonroot
|
||||
USER nonroot
|
||||
|
||||
# Install Node.js
|
||||
ENV NODE_VERSION 12.0.0
|
||||
ENV NVM_DIR /home/nonroot/.nvm
|
||||
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
|
||||
RUN curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
|
||||
# Check that Node.js was correctly installed
|
||||
RUN node --version
|
||||
|
||||
# Install Go
|
||||
ENV GO_VERSION 1.12.1
|
||||
ENV GOENV_ROOT /home/nonroot/.goenv
|
||||
ENV PATH $GOENV_ROOT/bin:$GOENV_ROOT/shims:$PATH
|
||||
RUN git clone https://github.com/syndbg/goenv.git $GOENV_ROOT \
|
||||
&& eval "$(goenv init -)" \
|
||||
&& goenv install $GO_VERSION \
|
||||
&& goenv global $GO_VERSION \
|
||||
&& chmod -R a+x $GOENV_ROOT
|
||||
# Check that Go was correctly installed
|
||||
RUN go version
|
||||
|
||||
# Install Ruby
|
||||
ENV RUBY_VERSION 2.6.3
|
||||
ENV RBENV_ROOT /home/nonroot/.rbenv
|
||||
ENV PATH $RBENV_ROOT/bin:$RBENV_ROOT/shims:$PATH
|
||||
RUN curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer | bash \
|
||||
&& rbenv install $RUBY_VERSION \
|
||||
&& rbenv global $RUBY_VERSION
|
||||
# Check that Ruby was correctly installed
|
||||
RUN ruby --version
|
||||
|
||||
# Install Python
|
||||
ENV PYTHON_VERSION 3.7.5
|
||||
ENV PYENV_ROOT /home/nonroot/.pyenv
|
||||
ENV PATH $PYENV_ROOT/bin:$PYENV_ROOT/shims:$PATH
|
||||
RUN curl https://pyenv.run | bash \
|
||||
&& pyenv install $PYTHON_VERSION \
|
||||
&& pyenv global $PYTHON_VERSION \
|
||||
&& chmod -R a+x $PYENV_ROOT
|
||||
# Check that Python was correctly installed
|
||||
RUN python --version
|
||||
|
||||
# Install Dotnet
|
||||
ENV DOTNET_HOME /home/nonroot/dotnet
|
||||
ENV DOTNET_SDK_VERSION 2.2.402
|
||||
|
||||
RUN mkdir -p "$DOTNET_HOME" \
|
||||
&& dotnet_download="$DOTNET_HOME/../dotnet.tar.gz" \
|
||||
&& curl -SL --output "$dotnet_download" https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-x64.tar.gz \
|
||||
&& tar -zxf "$dotnet_download" -C "$DOTNET_HOME" \
|
||||
&& rm "$dotnet_download"
|
||||
|
||||
ENV PATH $DOTNET_HOME:$PATH
|
||||
RUN dotnet help
|
||||
|
||||
# Install PHP
|
||||
ENV PHP_VERSION 7.3.8
|
||||
ENV PHPENV_ROOT /home/nonroot/.phpenv
|
||||
ENV PATH $PHPENV_ROOT/bin:$PHPENV_ROOT/shims:$PATH
|
||||
ENV CONFIGURE_OPTS "--without-tidy --disable-zip"
|
||||
RUN curl -L https://raw.githubusercontent.com/phpenv/phpenv-installer/master/bin/phpenv-installer | bash \
|
||||
&& phpenv install $PHP_VERSION \
|
||||
&& phpenv global $PHP_VERSION \
|
||||
&& chmod -R a+x $PHPENV_ROOT
|
||||
# Check that PHP was correctly installed
|
||||
RUN php --version
|
||||
|
||||
# Install Mercurial
|
||||
RUN HGPYTHON3=1 pip install mercurial
|
||||
# Check that Mercurial was correctly installed
|
||||
RUN hg --version
|
||||
# Install Terraform
|
||||
ENV TERRAFORM_HOME /home/nonroot/terraform
|
||||
ENV TERRAFORM_VERSION 0.12.14
|
||||
ENV PATH ${TERRAFORM_HOME}:${PATH}
|
||||
|
||||
RUN mkdir -p ${TERRAFORM_HOME} \
|
||||
&& terraform_download="${TERRAFORM_HOME}/terraform.zip" \
|
||||
&& curl -SL --output "${terraform_download}" "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" \
|
||||
&& unzip "${terraform_download}" -d "${TERRAFORM_HOME}" \
|
||||
&& rm "${terraform_download}"
|
||||
# Check that terraform was correctly installed
|
||||
RUN terraform version
|
||||
|
||||
# Create blank project
|
||||
RUN USER=nonroot cargo new --bin /src/starship
|
||||
WORKDIR /src/starship
|
||||
|
||||
# Copy the whole project
|
||||
COPY . .
|
||||
|
||||
# "-Z unstable-options" is required for "--include-ignored"
|
||||
CMD ["cargo", "test", "--", "-Z", "unstable-options", "--include-ignored"]
|
Loading…
Reference in New Issue
Block a user