Skip to content

Commit

Permalink
Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sjanusz-r7 committed Apr 10, 2024
1 parent e73f359 commit 154ab39
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 44 deletions.
44 changes: 6 additions & 38 deletions .github/workflows/smb_acceptance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,48 +45,30 @@ jobs:
runs-on: ${{ matrix.os }}
timeout-minutes: 40

services:
smb:
image: ${{ matrix.docker_image }}
ports:
- 445:445
- 139:139
env:
SMB_USERNAME: acceptance_tests_user
SMB_PASSWORD: acceptance_tests_password
options: >-
--health-cmd smbclient -U 'acceptance_tests_user%acceptance_tests_password' -L 127.0.0.1
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
fail-fast: true
matrix:
ruby:
- '3.2'
os:
- ubuntu-latest
docker_compose_path:
- docker-compose.yml
dockerfile_path:
- Dockerfile

env:
RAILS_ENV: test

name: ${{ matrix.dockerfile_path }} - ${{ matrix.os }} - Ruby ${{ matrix.ruby }}
name: Samba - ${{ matrix.os }} - Ruby ${{ matrix.ruby }}
steps:
- name: Install system dependencies
run: sudo apt-get install -y --no-install-recommends libpcap-dev graphviz smbclient
run: sudo apt-get install -y --no-install-recommends libpcap-dev graphviz

- name: Checkout code
uses: actions/checkout@v4

- name: Create Docker Image
working-directory: 'test/smb'
run: |
docker build -t smb-samba:v1 -f ${{ matrix.dockerfile_path }} .
docker compose build
docker compose up --wait -d
- name: Setup Ruby
env:
Expand All @@ -98,19 +80,11 @@ jobs:
ruby-version: '${{ matrix.ruby }}'
bundler-cache: true

- name: Extract runtime version
run: |
echo "RUNTIME_VERSION=ubuntu:22.04" >> $GITHUB_ENV
echo "DOCKER_IMAGE_FILENAME=smb-samba:v1" >> $GITHUB_ENV
env:
DOCKER_IMAGE: ${{ matrix.docker_image }}
OS: ${{ matrix.os }}

- name: acceptance
env:
SPEC_HELPER_LOAD_METASPLOIT: false
SPEC_OPTS: "--tag acceptance --require acceptance_spec_helper.rb --color --format documentation --format AllureRspec::RSpecFormatter"
RUNTIME_VERSION: ${{ env.RUNTIME_VERSION }}
RUNTIME_VERSION: 'latest'
# Unix run command:
# SPEC_HELPER_LOAD_METASPLOIT=false bundle exec ./spec/acceptance
# Windows cmd command:
Expand All @@ -119,20 +93,14 @@ jobs:
# Note: rspec retry is intentionally not used, as it can cause issues with allure's reporting
# Additionally - flakey tests should be fixed or marked as flakey instead of silently retried
run: |
docker run -d --rm --publish 445:445 --publish 139:139 smb-samba:v1 --name smb-acceptance
smbclient -U 'acceptance_tests_user%acceptance_tests_password' -L 127.0.0.1
bundle exec rspec spec/acceptance/smb_spec.rb
- name: Kill Docker Container
run: |
docker container kill smb-acceptance
- name: Archive results
if: always()
uses: actions/upload-artifact@v4
with:
# Provide a unique artifact for each matrix os, otherwise race conditions can lead to corrupt zips
name: ${{ env.DOCKER_IMAGE_FILENAME }}-${{ matrix.os }}
name: smb-samba-${{ matrix.os }}
path: tmp/allure-raw-data

# Generate a final report from the previous test results
Expand Down
5 changes: 1 addition & 4 deletions test/smb/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ EXPOSE 445 139
SHELL ["/bin/bash", "-c"]

# Install Samba
RUN apt update && apt install -y samba
RUN apt update && apt install -y samba smbclient

# To add a credential to Samba, the user needs to be created on the system
RUN useradd -m acceptance_tests_user

# Allow incoming Samba traffic - Is this necessary, or is UFW disabled by default?
#RUN ufw allow samba

# Configure a few shares
COPY shares shares

Expand Down
2 changes: 1 addition & 1 deletion test/smb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ docker compose build

- Run:
```shell
docker run -it --rm --publish 127.0.0.1:445:445 --publish 127.0.0.1:139:139 smb-samba:latest
docker compose up -d --wait
```

## Adding More Shares & Files
Expand Down
4 changes: 4 additions & 0 deletions test/smb/config/smb.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[global]
server min protocol = NT1
ntlm auth = yes

[modifiable]
comment = Samba on Ubuntu
path = /opt/shares/modifiable
Expand Down
8 changes: 7 additions & 1 deletion test/smb/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3'
version: '3.7'

services:
samba:
Expand All @@ -7,6 +7,12 @@ services:
ports:
- "139:139"
- "445:445"
healthcheck:
test: smbclient -U 'acceptance_tests_user%acceptance_tests_password' -L 127.0.0.1
interval: 10s
timeout: 5s
retries: 5
start_period: 5s
build:
context: .
dockerfile: Dockerfile

0 comments on commit 154ab39

Please sign in to comment.