Skip to content
Draft
Changes from 2 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
172 changes: 172 additions & 0 deletions .github/workflows/amazon_linux_2023_packaging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
name: Amazon Linux 2023 RPM Build and Test

on:
pull_request_target:

env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
S3_BUCKET_NAME: ${{ vars.S3_BUCKET_NAME }}
S3_REGION: ${{ vars.S3_REGION }}

permissions:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: can we move these above the env section?

id-token: write
contents: read

jobs:
al2023-package-test:
name: Amazon Linux 2023 RPM Build and Test
runs-on: ubuntu-latest
environment: PR integration tests
container:
image: amazonlinux:2023
options: --privileged

steps:
- name: Install Git
run: dnf -y install git

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v5
with:
role-to-assume: ${{ vars.ACTIONS_IAM_ROLE }}
aws-region: ${{ vars.S3_REGION }}

- name: Checkout code
uses: actions/checkout@v5
with:
ref: ${{ github.event.pull_request.head.sha }}
submodules: true
persist-credentials: false

- name: Install build tools and dependencies
run: |
dnf -y install rpm-build rpmdevtools make git \
mock \
ca-certificates \
python3 \
rust \
cargo \

cargo install cargo-about

- name: Generate Amazon Linux 2023 spec file
run: |
cd $GITHUB_WORKSPACE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can merge the cd commands

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, there should be quotes surrounding usage of environment variables

cd package
python3 generate_spec.py amzn2023
ls -la amzn2023-packaging.spec
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this here?


- name: Build source tarball and SRPM
run: |
cd $GITHUB_WORKSPACE

echo " Extracting version from spec file..."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this many echo statements?

VERSION=$(awk '/^Version:/ {print $2}' package/amzn2023-packaging.spec)
echo " Building version: $VERSION"

echo " Generating vendor dependencies..."
cargo vendor
echo " Cargo vendor completed"

echo " Generating license file..."
cargo about generate --config package/attribution.toml --output-file THIRD_PARTY_LICENSES package/attribution.hbs
echo "Third party License file generated"

echo " Setting up RPM build directory..."
rpmdev-setuptree
echo " RPM directories created"

cp package/amzn2023-packaging.spec ~/rpmbuild/SPECS/

cp LICENSE ~/rpmbuild/SOURCES/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These can all be merged together

cp NOTICE ~/rpmbuild/SOURCES/
cp THIRD_PARTY_LICENSES ~/rpmbuild/SOURCES/
echo "RPM Sources created"

echo " Creating source tarball..."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dance here is confusing - it's not obvious where our cwd is at any given point

cd ..
tar -czf mountpoint-s3-${VERSION}.tar.gz mountpoint-s3
ls -la
cp mountpoint-s3-${VERSION}.tar.gz ~/rpmbuild/SOURCES/
echo " Source tarball created"

echo " Checking SOURCES directory contents..."
ls -la ~/rpmbuild/SOURCES/
echo " Contents of SOURCES directory listed"

echo " Building Source RPM..."
rpmbuild -bs ~/rpmbuild/SPECS/amzn2023-packaging.spec
echo " SRPM build completed"

echo " Verifying SRPM was created..."
ls -la ~/rpmbuild/SRPMS/mount-s3-${VERSION}-amzn2023.src.rpm

# Export VERSION for next step
echo "VERSION=${VERSION}" >> $GITHUB_ENV

- name: Avoid PAM issues by installing sudo interactively
run: |
# https://github.com/geerlingguy/docker-rockylinux9-ansible/issues/6
echo "y" | dnf install sudo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dnf install -y

chmod 0400 /etc/shadow || true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why || true?


- name: Test RPM build with Mock in Amazon Linux 2023 chroot
run: |
echo " Building binary RPM for version: $VERSION"

sudo mock -r amazonlinux-2023-x86_64 --clean
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to run clean before the initial build?


sudo mock -r amazonlinux-2023-x86_64 --rebuild ~/rpmbuild/SRPMS/mount-s3-${VERSION}-amzn2023.src.rpm

echo "Files created"

ls -la /var/lib/mock/amazonlinux-2023-x86_64/result/

echo " Mock build completed"

- name: Test RPM installation
run: |
echo "Testing RPM installation..."

# Install the main binary RPM
echo "Installing mount-s3 RPM..."
dnf -y install /var/lib/mock/amazonlinux-2023-x86_64/result/mount-s3-${VERSION}-amzn2023.x86_64.rpm

# Verify installation
echo "Verifying installation..."
which mount-s3

# Test basic functionality
echo "Testing basic functionality..."
mount-s3 --version
mount-s3 --help | head -10

# Show what files were installed
echo "Files installed by RPM:"
rpm -ql mount-s3

# Show package info
echo "Package information:"
rpm -qi mount-s3

echo "RPM installation test completed successfully"

- name: Test mount with file operations
run: |
dnf -y install awscli

mkdir -p /mnt/s3-test

# Use allowed prefix: github-actions-tmp/
TEST_PREFIX="github-actions-tmp/run-${{ github.run_id }}/rpm-test/"

echo "Hello from RPM test" | aws s3 cp - "s3://${S3_BUCKET_NAME}/${TEST_PREFIX}test.txt"
mount-s3 ${S3_BUCKET_NAME} /mnt/s3-test --prefix=${TEST_PREFIX} --region=${S3_REGION}

ls -la /mnt/s3-test/
cat /mnt/s3-test/test.txt

sudo umount /mnt/s3-test
aws s3 rm "s3://${S3_BUCKET_NAME}/${TEST_PREFIX}test.txt"
Loading