Skip to content

Commit

Permalink
Merge pull request #29 from muselab-d2x/cumulusci-next-newbuildproc
Browse files Browse the repository at this point in the history
Configurable docker image/tag and new prebuilt -playwright, -chromedriver, and -full-browser images
  • Loading branch information
jlantz authored Sep 26, 2024
2 parents 1a6d007 + 07e41dd commit e59e48a
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 41 deletions.
69 changes: 44 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,50 @@
name: Build Docker Image

on:
push:
branches:
- cumulusci-next
workflow_dispatch:
push:
branches:
- main
- cumulusci-next**
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: ${{ github.event_name == 'push' }}
tags: |
ghcr.io/${{ github.repository }}:cumulusci-next
ghcr.io/${{ github.repository }}:${{ github.sha }}
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set environment variables
run: |
if [ "${{ github.ref_name }}" == "main" ]; then
echo "IMAGE_TAG=latest" >> $GITHUB_ENV
else
echo "IMAGE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
fi
- name: Build and push Docker images
uses: docker/build-push-action@v2
with:
context: .
push: ${{ github.event_name == 'push' }}
tags: |
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}-chromedriver
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}-playwright
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}-full-browser
outputs: |
type=image,name=ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }},target=no-browser
type=image,name=ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}-chromedriver,target=chromedriver
type=image,name=ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}-playwright,target=playwright
type=image,name=ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}-full-browser,target=full-browser
57 changes: 54 additions & 3 deletions .github/workflows/feature-test-2gp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,28 @@ on:
required: false
default: false
type: boolean
docker_image:
required: false
default: ghcr.io/muselab-d2x/d2x
type: string
docker_tag:
required: false
default: cumulusci-next
type: string
with_chromedriver:
required: false
default: false
type: boolean
with_playwright:
required: false
default: false
type: boolean
with_full_browser:
required: false
default: false
type: boolean

secrets:
# Either dev-hub-auth-url or dev-hub-username, dev-hub-client-id, and dev-hub-private-key are required
dev-hub-auth-url:
required: false
dev-hub-username:
Expand All @@ -32,11 +51,40 @@ on:
required: false

jobs:
select_d2x_docker_image:
name: "Select D2X Docker Image"
runs-on: ubuntu-latest
outputs:
tag_suffix: ${{ steps.set_tag_suffix.outputs.tag_suffix }}
steps:
- name: Calculate tag suffix
id: set_tag_suffix
run: |
TAG_SUFFIX=""
if [ "${{ inputs.with_full_browser }}" == "true" ]; then
TAG_SUFFIX=-full-browser
echo "Using full-browser image" >> $GITHUB_STEP_SUMMARY
elif [ "${{ inputs.with_chromedriver }}" == "true" ] && [ "${{ inputs.with_playwright }}" == "true" ]; then
TAG_SUFFIX=-full-browser
echo "Using full-browser image" >> $GITHUB_STEP_SUMMARY
elif [ "${{ inputs.with_chromedriver }}" == "true" ]; then
TAG_SUFFIX=-chromedriver
echo "Using chromedriver image" >> $GITHUB_STEP_SUMMARY
elif [ "${{ inputs.with_playwright }}" == "true" ]; then
TAG_SUFFIX=-playwright
echo "Using playwright image" >> $GITHUB_STEP_SUMMARY
else
TAG_SUFFIX=""
echo "Using default image" >> $GITHUB_STEP_SUMMARY
fi
echo "tag_suffix=$TAG_SUFFIX" >> $GITHUB_OUTPUT
feature-test:
name: "2GP Feature Test"
runs-on: ubuntu-latest
needs: select_d2x_docker_image
container:
image: ghcr.io/muselab-d2x/d2x:cumulusci-next
image: ${{ inputs.docker_image }}:${{ inputs.docker_tag }}${{ needs.select_d2x_docker_image.outputs.tag_suffix }}
options: --user root
credentials:
username: "${{ github.actor }}"
Expand All @@ -50,8 +98,11 @@ jobs:
GITHUB_APP_ID: "${{ secrets.github-app-id }}"
GITHUB_APP_KEY: "${{ secrets.github-app-key }}"
steps:
- name: Debug Docker Tag
run: |
echo "Using Docker image: ${{ inputs.docker_image }}:${{ inputs.docker_tag }}${{ needs.select_d2x_docker_image.outputs.tag_suffix }}"
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Auth to DevHub
run: /usr/local/bin/devhub.sh
- name: Set ${{ inputs.org }} org as default org
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release-1gp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
inputs:
release-name:
required: false
description: "The name of the release to upload to the production org."
type: string
secrets:
dev-hub-auth-url:
Expand Down
57 changes: 44 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
FROM salesforce/cli:latest-full
# Base stage
FROM salesforce/cli:latest-full AS base

LABEL org.opencontainers.image.source = "https://github.com/muselab-d2x/d2x"
LABEL org.opencontainers.image.source="https://github.com/muselab-d2x/d2x"

# Install Python
RUN apt-get update; \
apt-get upgrade -y; \
apt-get install -y python3-pip
RUN apt-get update && apt-get upgrade -y && apt-get install -y python3-pip

# Install GitHub CLI
RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg; \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null; \
apt-get install -y gh
RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null && \
apt-get update && apt-get install -y gh

# Install CumulusCI
RUN pip --no-cache-dir install git+https://github.com/muselab-d2x/CumulusCI@d2x cookiecutter
Expand All @@ -23,10 +22,42 @@ RUN chmod +x /usr/local/bin/devhub.sh
RUN useradd -r -m -s /bin/bash -c "D2X User" d2x

# Setup PATH
RUN echo 'export PATH=~/.local/bin:$PATH' >> /root/.bashrc
RUN echo 'export PATH=~/.local/bin:$PATH' >> /home/d2x/.bashrc
RUN echo '/usr/local/bin/devhub.sh' >> /root/.bashrc
RUN echo '/usr/local/bin/devhub.sh' >> /home/d2x/.bashrc
RUN echo 'export PATH=~/.local/bin:$PATH' >> /root/.bashrc && \
echo 'export PATH=~/.local/bin:$PATH' >> /home/d2x/.bashrc && \
echo '/usr/local/bin/devhub.sh' >> /root/.bashrc && \
echo '/usr/local/bin/devhub.sh' >> /home/d2x/.bashrc

# Stage for ChromeDriver
FROM base AS chromedriver

# Install ChromeDriver
RUN apt-get install -y wget unzip && \
wget -O /tmp/chromedriver.zip https://chromedriver.storage.googleapis.com/$(curl -s https://chromedriver.storage.googleapis.com/LATEST_RELEASE)/chromedriver_linux64.zip && \
unzip /tmp/chromedriver.zip -d /usr/local/bin/ && \
rm /tmp/chromedriver.zip

# Stage for Playwright
FROM base AS playwright

# Install Playwright
RUN npm install -g playwright && \
npx playwright install

# Stage for full browser support (ChromeDriver + Playwright)
FROM base AS full-browser

# Install ChromeDriver
RUN apt-get install -y wget unzip && \
wget -O /tmp/chromedriver.zip https://chromedriver.storage.googleapis.com/$(curl -s https://chromedriver.storage.googleapis.com/LATEST_RELEASE)/chromedriver_linux64.zip && \
unzip /tmp/chromedriver.zip -d /usr/local/bin/ && \
rm /tmp/chromedriver.zip

# Install Playwright
RUN npm install -g playwright && \
npx playwright install

# Final stage for no browser automation support
FROM base AS no-browser

USER d2x
CMD ["bash"]
CMD ["bash"]

0 comments on commit e59e48a

Please sign in to comment.