Skip to content
Draft
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
109 changes: 109 additions & 0 deletions .github/workflows/al2023_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: AL2023 RPM Build Tests

on:
pull_request_target:

permissions:
id-token: write
contents: read

env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
S3_BUCKET_NAME: ${{ vars.S3_BUCKET_NAME }}
S3_REGION: ${{ vars.S3_REGION }}
TEST_PREFIX: "github-actions-tmp/run-${{ github.run_id }}/rpm-test/"

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

steps:
- name: Install build tools and dependencies
run: |
dnf -y install git rpm-build rpmdevtools make mock ca-certificates rust cargo sudo awscli
cargo install cargo-about

- name: Install uv
uses: astral-sh/setup-uv@v6
Comment on lines +32 to +33
Copy link
Contributor

Choose a reason for hiding this comment

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

If you push another rev, can you bump this to V7?

rel: #1649


- name: Preventing container PAM sudo errors
run: |
# https://github.com/geerlingguy/docker-rockylinux9-ansible/issues/6
chmod 0400 /etc/shadow

- 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:
submodules: true
persist-credentials: false

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

Choose a reason for hiding this comment

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

Why do we need to use cd here?

uv run python generate_spec.py amzn2023 && mv amzn2023.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 do we need to move the output file rather than including an argument for where to write it in the first place?

echo "## Generated Amazon Linux 2023 Spec File" >> $GITHUB_STEP_SUMMARY
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way of doing a multi-line echo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@muddyfish There are 3 ways of doing that, im not sure which one you meant?

1. Heredoc

cat << 'EOF' >> $GITHUB_STEP_SUMMARY
## Generated Amazon Linux 2023 Spec File

```spec
EOF
cat ../amzn2023.spec >> $GITHUB_STEP_SUMMARY
cat << 'EOF' >> $GITHUB_STEP_SUMMARY
```
EOF

2. Multiline echo

echo -e "## Generated Amazon Linux 2023 Spec File\n\n\`\`\`spec" >> $GITHUB_STEP_SUMMARY
cat ../amzn2023.spec >> $GITHUB_STEP_SUMMARY
echo -e "\n\`\`\`" >> $GITHUB_STEP_SUMMARY

3. Command grouping

{
    echo "## Generated Amazon Linux 2023 Spec File"
    echo ""
    echo '```spec'
    cat ../amzn2023.spec
    echo ""
    echo '```'
} >> $GITHUB_STEP_SUMMARY

Copy link
Contributor

@muddyfish muddyfish Oct 14, 2025

Choose a reason for hiding this comment

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

Can we do something like $(cat ../amzn2023.spec)? If so, adding that to the option 1 sounds best

echo "" >> $GITHUB_STEP_SUMMARY
echo '```spec' >> $GITHUB_STEP_SUMMARY
cat ../amzn2023.spec >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY

- name: Build source tarball and SRPM
run: |
VERSION=$(awk '/^Version:/ {print $2}' amzn2023.spec)
cargo vendor
cargo about generate --config package/attribution.toml --output-file THIRD_PARTY_LICENSES package/attribution.hbs
rpmdev-setuptree

cp amzn2023.spec ~/rpmbuild/SPECS/
cp LICENSE NOTICE THIRD_PARTY_LICENSES ~/rpmbuild/SOURCES

cd ..
tar -czf "mountpoint-s3-${VERSION}.tar.gz" mountpoint-s3
cp "mountpoint-s3-${VERSION}.tar.gz" ~/rpmbuild/SOURCES/
rpmbuild -bs ~/rpmbuild/SPECS/amzn2023.spec
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"

- name: Test RPM build with Mock in Amazon Linux 2023 chroot
run: |
sudo mock -r amazonlinux-2023-x86_64 --rebuild ~/rpmbuild/SRPMS/mount-s3-${VERSION}-amzn2023.src.rpm

- name: Test RPM installation
run: |
dnf -y install /var/lib/mock/amazonlinux-2023-x86_64/result/mount-s3-${VERSION}-amzn2023.x86_64.rpm
which mount-s3
mount-s3 --version
mount-s3 --help

- name: Basic Functionality Tests
run: |
mkdir -p /mnt/s3-test

# Read 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}"
cat /mnt/s3-test/test.txt | grep -q "Hello from RPM test"

# Write Test
echo "Hello from RPM write test" > /mnt/s3-test/write-test.txt
aws s3 cp "s3://${S3_BUCKET_NAME}/${TEST_PREFIX}write-test.txt" - | grep -q "Hello from RPM write test"

sudo umount /mnt/s3-test

- name: Cleanup test resources
if: always()
run: |
aws s3 rm "s3://${S3_BUCKET_NAME}/${TEST_PREFIX}test.txt"
aws s3 rm "s3://${S3_BUCKET_NAME}/${TEST_PREFIX}write-test.txt"
Loading