Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NOID] Fixing github action builds to be able to download docker images and maven dependencies from correct places depending on branch #4178

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions .github/actions/test-gradle-project/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ runs:
- uses: ./.github/actions/setup-gradle-cache
- name: Run compile tests
shell: bash
run: ./gradlew --info -Pneo4jVersionOverride=$NEO4J_VERSION_CI :${{inputs.project-name}}:compileJava :${{inputs.project-name}}:compileTestJava
run: ./gradlew --info -Pneo4jVersionOverride=$NEO4JVERSION -Pneo4jDockerEeOverride=$NEO4J_ENTERPRISE_IMAGE -Pneo4jDockerCeOverride=$NEO4J_COMMUNITY_IMAGE :${{inputs.project-name}}:compileJava :${{inputs.project-name}}:compileTestJava
- name: Run tests
shell: bash
run: ./gradlew --info -Pneo4jVersionOverride=$NEO4J_VERSION_CI :${{inputs.project-name}}:check --parallel
run: ./gradlew --info -Pneo4jVersionOverride=$NEO4JVERSION -Pneo4jDockerEeOverride=$NEO4J_ENTERPRISE_IMAGE -Pneo4jDockerCeOverride=$NEO4J_COMMUNITY_IMAGE :${{inputs.project-name}}:check --parallel
- name: Archive test results
uses: actions/upload-artifact@v2
if: always()
Expand Down
60 changes: 48 additions & 12 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ on:
branches: [ "dev" ]

env:
CODEARTIFACT_DOWNLOAD_URL: ${{ secrets.CODEARTIFACT_DOWNLOAD_URL }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
CODEARTIFACT_URL: ${{ secrets.CODEARTIFACT_URL }}
CODEARTIFACT_USERNAME: ${{ secrets.CODEARTIFACT_USERNAME }}
ECR_NEO4J_DOCKER_URL: ${{ secrets.ECR_NEO4J_DOCKER_URL }}


jobs:
Expand Down Expand Up @@ -40,26 +42,34 @@ jobs:
- uses: ./.github/actions/setup-jdk
- uses: ./.github/actions/setup-gradle-cache

- name: Determine latest neo4j CI version
- name: Determine Remote Maven Repository, Neo4j Version and Neo4j Docker Images
run: |
neo4j_version_base=$(grep -e "neo4jVersion = .*" build.gradle | cut -d '=' -f 2 | tr -d \'\" | tr -d ' ')
echo "neo4j_version_base=$neo4j_version_base"
NEO4J_VERSION_CI=`aws codeartifact list-package-versions --domain build-service-live --domain-owner ${{ secrets.AWS_ACCOUNT_ID }} --repository ci-live --format maven --namespace org.neo4j --package neo4j --sort-by PUBLISHED_TIME --query "versions[?starts_with(version,'$neo4j_version_base')] | [0].version" | tr -d '" '`
echo "NEO4J_VERSION_CI=$NEO4J_VERSION_CI" >> "$GITHUB_ENV"
echo "Found NEO4j_VERSION_CI=$NEO4J_VERSION_CI"
echo "Analyzing current branch BRANCH_NAME=$BRANCH_NAME"
if [[ $BRANCH_NAME =~ ^5.[0-9]+$ ]]; then
NEO4JVERSION="$neo4j_version_base"
else
NEO4JVERSION="$neo4j_version_base-SNAPSHOT"
CODEARTIFACT_DOWNLOAD_URL="$CODEARTIFACT_URL/ci-live"
echo "CODEARTIFACT_DOWNLOAD_URL=$CODEARTIFACT_DOWNLOAD_URL"
echo "CODEARTIFACT_DOWNLOAD_URL=$CODEARTIFACT_DOWNLOAD_URL" >> "$GITHUB_ENV"
fi
echo "NEO4JVERSION=$NEO4JVERSION"
echo "NEO4JVERSION=$NEO4JVERSION" >> "$GITHUB_ENV"

- name: Compile Java
run: |
chmod +x gradlew
./gradlew --no-daemon --info -Pneo4jVersionOverride=$NEO4J_VERSION_CI --init-script init.gradle clean
./gradlew --no-daemon --info -Pneo4jVersionOverride=$NEO4JVERSION --init-script init.gradle clean
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

- name: Compile
run: ./gradlew --info -Pneo4jVersionOverride=$NEO4J_VERSION_CI compileJava compileTestJava
run: ./gradlew --info -Pneo4jVersionOverride=$NEO4JVERSION compileJava compileTestJava

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
Expand Down Expand Up @@ -99,18 +109,44 @@ jobs:
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}

- name: Determine latest neo4j CI version
- name: Determine Remote Maven Repository, Neo4j Version and Neo4j Docker Images
run: |
neo4j_version_base=$(grep -e "neo4jVersion = .*" build.gradle | cut -d '=' -f 2 | tr -d \'\" | tr -d ' ')
echo "neo4j_version_base=$neo4j_version_base"
NEO4J_VERSION_CI=`aws codeartifact list-package-versions --domain build-service-live --domain-owner ${{ secrets.AWS_ACCOUNT_ID }} --repository ci-live --format maven --namespace org.neo4j --package neo4j --sort-by PUBLISHED_TIME --query "versions[?starts_with(version,'$neo4j_version_base')] | [0].version" | tr -d '" '`
echo "NEO4J_VERSION_CI=$NEO4J_VERSION_CI" >> "$GITHUB_ENV"
echo "Found NEO4j_VERSION_CI=$NEO4J_VERSION_CI"
echo "Analyzing current branch BRANCH_NAME=$BRANCH_NAME"
if [[ $BRANCH_NAME =~ ^5.[0-9]+$ ]]; then
NEO4JVERSION="$neo4j_version_base"
NEO4J_ENTERPRISE_IMAGE="neo4j:$NEO4JVERSION-enterprise"
NEO4J_COMMUNITY_IMAGE="neo4j:$NEO4JVERSION-community"
echo "DOCKER_REMOTE=Dockerhub" >> "$GITHUB_ENV"
else
NEO4JVERSION="$neo4j_version_base-SNAPSHOT"
NEO4J_ENTERPRISE_IMAGE="${{ secrets.ECR_NEO4J_DOCKER_URL }}/build-service/neo4j:$neo4j_version_base-enterprise-debian-nightly"
NEO4J_COMMUNITY_IMAGE="${{ secrets.ECR_NEO4J_DOCKER_URL }}/build-service/neo4j:$neo4j_version_base-community-debian-nightly"
echo "DOCKER_REMOTE=ECR" >> "$GITHUB_ENV"
CODEARTIFACT_DOWNLOAD_URL="$CODEARTIFACT_URL/ci-live"
echo "CODEARTIFACT_DOWNLOAD_URL=$CODEARTIFACT_DOWNLOAD_URL"
echo "CODEARTIFACT_DOWNLOAD_URL=$CODEARTIFACT_DOWNLOAD_URL" >> "$GITHUB_ENV"
fi
echo "NEO4JVERSION=$NEO4JVERSION"
echo "NEO4JVERSION=$NEO4JVERSION" >> "$GITHUB_ENV"
echo "NEO4J_ENTERPRISE_IMAGE=$NEO4J_ENTERPRISE_IMAGE"
echo "NEO4J_ENTERPRISE_IMAGE=$NEO4J_ENTERPRISE_IMAGE" >> "$GITHUB_ENV"
echo "NEO4J_COMMUNITY_IMAGE=$NEO4J_COMMUNITY_IMAGE"
echo "NEO4J_COMMUNITY_IMAGE=$NEO4J_COMMUNITY_IMAGE" >> "$GITHUB_ENV"

- name: Login to ECR
if: env.DOCKER_REMOTE == 'ECR'
uses: docker/login-action@v3
with:
registry: ${{ secrets.ECR_NEO4J_DOCKER_URL }}
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: Init gradle
run: |
chmod +x gradlew
./gradlew --info -Pneo4jVersionOverride=$NEO4J_VERSION_CI --init-script init.gradle
./gradlew --info -Pneo4jVersionOverride=$NEO4JVERSION --init-script init.gradle

- name: Run ${{ matrix.project }} tests
uses: ./.github/actions/test-gradle-project
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ subprojects {
// neo4jDockerImage system property is used in TestContainerUtil
systemProperties 'user.language' : 'en' ,
'user.country' : 'US',
'neo4jDockerImage' : System.getProperty("NEO4JVERSION") ? 'neo4j:' + System.getProperty("NEO4JVERSION") + '-enterprise-debian' : 'neo4j:5.23.0-enterprise',
'neo4jCommunityDockerImage': System.getProperty("NEO4JVERSION") ? 'neo4j:' + System.getProperty("NEO4JVERSION") + '-debian' : 'neo4j:5.23.0',
'neo4jDockerImage': project.hasProperty("neo4jDockerEeOverride") ? project.getProperty("neo4jDockerEeOverride") : 'neo4j:5.23.0-enterprise-debian',
'neo4jCommunityDockerImage': project.hasProperty("neo4jDockerCeOverride") ? project.getProperty("neo4jDockerCeOverride") : 'neo4j:5.23.0-debian',
'coreDir': 'apoc-core/core',
'testDockerBundle': false

Expand Down
Loading