Skip to content

Commit

Permalink
Creates container for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cuducos authored and Eduardo Vicente Gonçalves committed Apr 10, 2023
1 parent a172816 commit 7925bd2
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 15 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Container
on:
push:
branches: ['main']

jobs:
build-and-push-image:
env:
IMAGE_NAME: ${{ github.repository }}
REGISTRY: ghcr.io
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
strategy:
matrix:
neovim: [stable, nightly]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-neovim-${{ matrix.neovim }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
19 changes: 19 additions & 0 deletions .github/workflows/stylua.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
on: [push, pull_request]
name: Stylua

jobs:

stylua:
runs-on: ubuntu-latest
strategy:
matrix:
nvim-versions: ["stable", "nightly"]
name: Stylua
steps:
- uses: actions/checkout@v3
- uses: JohnnyMorganz/stylua-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: latest
args: --check .
16 changes: 1 addition & 15 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
---
on: [push, pull_request]
name: main
name: Tests

jobs:

stylua:
runs-on: ubuntu-latest
strategy:
matrix:
nvim-versions: ["stable", "nightly"]
name: Stylua
steps:
- uses: actions/checkout@v3
- uses: JohnnyMorganz/stylua-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: latest
args: --check .

tests:
runs-on: ubuntu-latest
strategy:
Expand Down
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM debian:bullseye-slim AS neovim
ARG NVIM_VERSION
ENV NVIM_VERSION=${NVIM_VERSION:-stable}
ENV BUILD_REQUIREMENTS "cmake curl gcc gettext git ninja-build unzip"
RUN apt-get update && \
apt-get install -y ${BUILD_REQUIREMENTS} && \
git clone --branch ${NVIM_VERSION} https://github.com/neovim/neovim && \
cd neovim && \
make install && \
rm -rf ../neovim && \
apt-get remove -y ${BUILD_REQUIREMENTS} && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*

FROM rust:slim-bullseye AS tree-sitter-cli
RUN cargo install tree-sitter-cli

FROM debian:bullseye-slim
COPY --from=neovim /usr/local/share/nvim /usr/local/share/nvim
COPY --from=neovim /usr/local/lib/nvim /usr/local/lib/nvim
COPY --from=neovim /usr/local/bin/nvim /usr/local/bin/nvim
COPY --from=tree-sitter-cli /usr/local/cargo/bin/tree-sitter /usr/local/bin/tree-sitter

RUN apt-get update && \
apt-get install -y curl g++ git && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/* && \
useradd -ms /bin/bash yaml

USER yaml
WORKDIR /home/yaml/
RUN mkdir -p .config/nvim/
ADD tests/init.lua .config/nvim/init.lua
ADD . .

CMD ["nvim", "--headless", "-c", "PlenaryBustedDirectory tests/yaml_nvim { minimal_init = 'tests/init.lua' }"]

0 comments on commit 7925bd2

Please sign in to comment.