Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .ci-info.json

This file was deleted.

7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.git
.github
.vscode
ftpserver
ftpserver.json
ftpserver.log
*.pem
28 changes: 6 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,27 @@
name: Build

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
pull_request:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-26.04

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE
- uses: actions/checkout@v7.0.1

# Running golangci-lint
- name: Linting
if: matrix.lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.15.0

# Install Go
- name: Setup go
uses: actions/setup-go@v7.0.0
with:
go-version: 1.27.3

- name: Linting
uses: golangci/golangci-lint-action@v9
with:
version: v2.15.0

- name: Build
run: go build -v ./...

- name: Test
# We need GCC because of the "go test -race"
# env:
# CGO_ENABLED: 0
run: |
apt-get update && apt-get install gcc -y
go test -race -v ./...
run: go test -race -v ./...
37 changes: 2 additions & 35 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ master ]
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
branches: [ main ]
schedule:
- cron: '44 20 * * 0'

Expand All @@ -29,39 +17,18 @@ jobs:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v7.0.1

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v4

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
66 changes: 41 additions & 25 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,59 @@
name: Test the current docker image
name: Test the docker image

on:
schedule:
# We want to run it every day
- cron: '0 0 * * *'
# We want to check the published image every day
- cron: '0 0 * * *'
pull_request:
paths:
- Dockerfile*
- .dockerignore
- .github/workflows/docker-test.yml
workflow_dispatch:

jobs:
test-docker-image:
strategy:
fail-fast: false
matrix:
tag: ["latest", "alpine"]
runs-on: ubuntu-26.04
timeout-minutes: 1
services:
ftpserver:
image: fclairamb/ftpserver
ports:
- 2121-2130:2121-2130

timeout-minutes: 15
env:
SERVER_PORT: 2121
steps:
- name: Run sample
env:
SERVER_PORT: 2121
- uses: actions/checkout@v7.0.1
if: github.event_name == 'pull_request'

- name: Build the image
if: github.event_name == 'pull_request'
run: |
docker build -t "fclairamb/ftpserver:${{ matrix.tag }}" \
-f "Dockerfile${{ matrix.tag == 'alpine' && '.alpine' || '' }}" .

- name: Start the server
run: |
docker run -d --name ftpserver -p 2121-2130:2121-2130 "fclairamb/ftpserver:${{ matrix.tag }}"

- name: Upload and download a file
run: |
set -xe

# Getting a file
curl https://placekitten.com/2048/2048 -o kitty.jpg
# Generating a file
head -c 2097152 /dev/urandom > local.bin

# Waiting for server to be ready
while ! nc -z localhost ${SERVER_PORT} </dev/null; do sleep 1; done
timeout 30 sh -c "while ! nc -z localhost ${SERVER_PORT} </dev/null; do sleep 1; done"

# Upload a file
curl -v -T kitty.jpg ftp://test:test@localhost:${SERVER_PORT}/remote.jpg
curl -v -T local.bin "ftp://test:test@localhost:${SERVER_PORT}/remote.bin"

# Download a file
curl -v ftp://test:test@localhost:2121/remote.jpg -o remote.jpg

# Checking that the output file exists
if [ ! -f remote.jpg ]; then
exit 1
fi
# Download it back
curl -v "ftp://test:test@localhost:${SERVER_PORT}/remote.bin" -o remote.bin

# Comparing file contents
diff kitty.jpg remote.jpg
cmp local.bin remote.bin

- name: Server logs
if: always()
run: docker logs ftpserver
101 changes: 62 additions & 39 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,68 @@
name: Build docker images

# Images are published when a release is created. Releases are cut by release-please with the default
# GITHUB_TOKEN, whose events never trigger another workflow, so release-please.yml calls this workflow
# directly (see #1738). Pull requests only check that the images still build.
on:
workflow_call:
inputs:
tag:
description: 'Tag of the release to build the images for'
required: true
type: string
workflow_dispatch:
inputs:
tag:
description: 'Tag of the release to build the images for (e.g. v0.16.3)'
required: true
type: string
push:
#branches: # At least when doing some tests
# - "**"
tags:
- "v*.*.*"
# pull_request:
# TODO: remove before merging, only used to test the Docker Hub / GHCR upload from this branch
branches:
- chore/cleanup
pull_request:
paths:
- Dockerfile*
- .dockerignore
- .github/workflows/docker.yml

permissions:
contents: read
packages: write
attestations: write
id-token: write

jobs:
build-and-push:
strategy:
fail-fast: false
matrix:
type: ["", "alpine"]
runs-on: ubuntu-26.04
env:
PUSH: ${{ github.repository == 'fclairamb/ftpserver' && github.event_name != 'pull_request' }}
steps:
- name: Resolve tag
id: tag
# `inputs` is empty on a tag push, in which case the ref is the tag itself.
run: |
tag='${{ inputs.tag }}'
if [ -z "${tag}" ] && [ '${{ github.ref_type }}' = 'tag' ]; then
tag='${{ github.ref_name }}'
fi
echo "tag=${tag}" >> "$GITHUB_OUTPUT"

- name: Checkout
uses: actions/checkout@v7.0.1
with:
fetch-depth: 0
- name: Setup go
uses: actions/setup-go@v7.0.0
with:
go-version-file: go.mod
- name: Change version
ref: ${{ steps.tag.outputs.tag || github.sha }}

- name: Resolve build info
id: build
run: |
curl -L https://github.com/fclairamb/ci-info/releases/download/v0.4.4/ci-info_0.4.4_linux_amd64.tar.gz | tar -zx
./ci-info
echo "commit=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
echo "date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "$GITHUB_OUTPUT"

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v6
Expand All @@ -44,50 +74,43 @@ jobs:
suffix=${{ matrix.type != '' && format('-{0}', matrix.type) || '' }}
latest=false
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=semver,suffix=,pattern=${{ matrix.type != '' && matrix.type || 'latest' }}
type=ref,event=branch
type=semver,pattern={{version}},value=${{ steps.tag.outputs.tag }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.tag.outputs.tag }}
type=semver,pattern={{major}},value=${{ steps.tag.outputs.tag }}
type=semver,suffix=,pattern=${{ matrix.type != '' && matrix.type || 'latest' }},value=${{ steps.tag.outputs.tag }}
type=ref,event=pr
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
type=ref,event=branch

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Cache Docker layers
uses: actions/cache@v6
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ matrix.type }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Login to DockerHub
if: github.repository == 'fclairamb/ftpserver'
if: env.PUSH == 'true'
uses: docker/login-action@v4
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Container Registry
if: github.repository == 'fclairamb/ftpserver'
if: env.PUSH == 'true'
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push (scratch)

- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile${{ matrix.type != '' && format('.{0}', matrix.type) || '' }}
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
push: ${{ github.repository == 'fclairamb/ftpserver' }}
push: ${{ env.PUSH == 'true' }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

build-and-push-status:
needs: build-and-push
runs-on: ubuntu-26.04
steps:
- run: echo 'All good'
build-args: |
VERSION=${{ steps.tag.outputs.tag || 'dev' }}
COMMIT=${{ steps.build.outputs.commit }}
BUILD_DATE=${{ steps.build.outputs.date }}
cache-from: type=gha,scope=docker${{ matrix.type }}
cache-to: type=gha,mode=max,scope=docker${{ matrix.type }}
Loading
Loading