Skip to content

Commit

Permalink
Merge pull request #484 from AOEpeople/update/#264482-pipeline-duration
Browse files Browse the repository at this point in the history
Update/#264482 pipeline duration
  • Loading branch information
MalibusParty authored Jul 9, 2024
2 parents 488e2c3 + deb1236 commit 2c1e8fe
Show file tree
Hide file tree
Showing 8 changed files with 1,569 additions and 61 deletions.
133 changes: 93 additions & 40 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,66 @@ jobs:
working-directory: ./src/Resources
run: yarn test

buildDevImage:
name: Build Development Docker Images
runs-on: ubuntu-latest
needs: [ test-cgl, psalm, phpmd, format, lint, testFrontendUnitFunctional ]
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 10
- name: Prepare build
run: |
mkdir -p /tmp/docker/buildx
git log -n 10 --date=short --format=format:"%C(auto)%h %ad @%al %s" >> public/changelog.txt
- name: Setup docker build caches
uses: actions/cache@v4
with:
key: ${{ runner.os }}-buildx
path: /tmp/docker/buildx
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
# Development image
- name: Get Docker meta for development
id: devmeta
uses: docker/metadata-action@v5
with:
images: aoepeople/meals:beta
tags: |
type=sha
type=ref,event=branch
- name: Build and push development image
id: build_dev
uses: docker/build-push-action@v6
with:
file: Dockerfile
push: false
tags: aoepeople/meals:test
labels: ${{ steps.devmeta.outputs.labels }}
build-args: |
BUILD_DEV="true"
cache-from: |
aoepeople/meals:beta
type=local,src=/tmp/docker/buildx
cache-to: type=local,dest=/tmp/docker/buildx
outputs: type=docker,dest=/tmp/docker/dev.tar
# Upload artifacts
- name: Upload docker images
uses: actions/upload-artifact@v4
with:
name: docker-dev-image
path: /tmp/docker/*.tar
outputs:
imageDev: aoepeople/meals:test

buildImages:
name: Build Docker Images
runs-on: ubuntu-latest
Expand Down Expand Up @@ -176,49 +236,28 @@ jobs:
type=local,src=/tmp/docker/buildx
cache-to: type=local,dest=/tmp/docker/buildx
outputs: type=docker,dest=/tmp/docker/app.tar
# Development image
- name: Get Docker meta for development
id: devmeta
uses: docker/metadata-action@v5
with:
images: aoepeople/meals:beta
tags: |
type=sha
type=ref,event=branch
- name: Build and push development image
id: build_dev
uses: docker/build-push-action@v6
with:
file: Dockerfile
push: false
tags: aoepeople/meals:test
labels: ${{ steps.devmeta.outputs.labels }}
build-args: |
BUILD_DEV="true"
cache-from: |
aoepeople/meals:beta
type=local,src=/tmp/docker/buildx
cache-to: type=local,dest=/tmp/docker/buildx
outputs: type=docker,dest=/tmp/docker/dev.tar
# Upload artifacts
- name: Upload docker images
uses: actions/upload-artifact@v4
with:
name: docker-images
name: docker-app-image
path: /tmp/docker/*.tar
outputs:
image: ${{ fromJson(steps.meta.outputs.json).tags[0] }}
images: ${{ join(steps.meta.outputs.tags, ' ') }}
imageDev: aoepeople/meals:test

cypress:
name: Run E2E-tests via Cypress
needs: [ buildImages ]
needs: [ buildDevImage ]
runs-on: ubuntu-latest
env:
SERVICE: dev # use `dev` to enable xdebug and code coverage
IMAGE_DEV: ${{ needs.buildImages.outputs.imageDev }}
IMAGE_DEV: ${{ needs.buildDevImage.outputs.imageDev }}
COMPOSE_INTERACTIVE_NO_CLI: true
strategy:
fail-fast: false
matrix:
containers: [1, 2, 3, 4]
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -227,7 +266,7 @@ jobs:
- name: Download docker images
uses: actions/download-artifact@v4
with:
name: docker-images
name: docker-dev-image
path: /tmp/docker
- name: Import docker image
run: |
Expand Down Expand Up @@ -261,28 +300,33 @@ jobs:
printf '.'
sleep 5
done &&
yarn --cwd=./tests/e2e cross-env-shell cypress run --headless --browser electron --env "baseUrl=http://localhost/,cookie_domain=localhost,ddev_test=false,mailhog_url=http://localhost:8025"
yarn --cwd=./tests/e2e cross-env-shell cypress run --headless --browser electron --env "baseUrl=http://localhost/,cookie_domain=localhost,ddev_test=false,mailhog_url=http://localhost:8025","split=${{ strategy.job-total }}","splitIndex=${{ strategy.job-index }}"
- name: Docker compose down
run: |
docker compose -f docker-compose-cypress.yaml down --remove-orphans
testBackendUnitFunctional:
name: Run backend unit- and functional-tests
needs: [ buildImages ]
needs: [ buildImages, buildDevImage ]
runs-on: ubuntu-latest
env:
SERVICE: app # use `dev` to enable xdebug and code coverage
IMAGE: ${{ needs.buildImages.outputs.image }}
IMAGE_DEV: ${{ needs.buildImages.outputs.imageDev }}
IMAGE_DEV: ${{ needs.buildDevImage.outputs.imageDev }}
COMPOSE_INTERACTIVE_NO_CLI: true
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: actions/checkout@v4
- name: Download docker images
- name: Download docker app-image
uses: actions/download-artifact@v4
with:
name: docker-app-image
path: /tmp/docker
- name: Download docker dev-image
uses: actions/download-artifact@v4
with:
name: docker-images
name: docker-dev-image
path: /tmp/docker
- name: Import docker image
run: |
Expand All @@ -309,11 +353,11 @@ jobs:
publish:
name: Publish
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
needs: [ buildImages, testBackendUnitFunctional, cypress ]
needs: [ buildImages, buildDevImage, testBackendUnitFunctional, cypress ]
runs-on: ubuntu-latest
env:
IMAGES_APP: ${{ needs.buildImages.outputs.images }}
IMAGE_DEV: ${{ needs.buildImages.outputs.imageDev }}
IMAGE_DEV: ${{ needs.buildDevImage.outputs.imageDev }}
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -322,10 +366,15 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Download docker images
- name: Download docker app-image
uses: actions/download-artifact@v4
with:
name: docker-images
name: docker-app-image
path: /tmp/docker
- name: Download docker dev-image
uses: actions/download-artifact@v4
with:
name: docker-dev-image
path: /tmp/docker
- name: Import docker image
run: |
Expand Down Expand Up @@ -358,7 +407,11 @@ jobs:
- name: Delete docker image artifact
uses: geekyeggo/delete-artifact@v5
with:
name: docker-images
name: docker-dev-image
- name: Delete docker image artifact
uses: geekyeggo/delete-artifact@v5
with:
name: docker-app-image
outputs:
imageDigest: ${{ steps.image_digest.outputs.digest }}

Expand Down Expand Up @@ -386,7 +439,7 @@ jobs:
# Replace any "null" security severity values with 0. The null value is used in the case
# of license-related findings, which do not do not indicate a security vulnerability.
# See https://github.com/github/codeql-action/issues/2187 for more context.
- name: Post process snyk sarif file
- name: Post process snyk sarif file
run: |
sed -i 's/"security-severity": "null"/"security-severity": "0"/g' snyk.sarif
- name: Upload result to GitHub Code Scanning
Expand Down
2 changes: 1 addition & 1 deletion src/Mealz/MealBundle/DataFixtures/ORM/LoadDishes.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function load(ObjectManager $manager): void
'Limbs oh la la la (Ofen gebacken) + Finger food mit einer schlammigen Süß-Sauer-Soße'
);

for ($i = 0; $i < 150; ++$i) {
for ($i = 0; $i < 30; ++$i) {
$this->createRandomDish();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Mealz/MealBundle/DataFixtures/ORM/LoadWeeks.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private function getCurrentTestWeeks(): array
{
$currentWeeks = [];
$date = new DateTime('first monday of -5 months');
$maxDate = new DateTime('+1 month');
$maxDate = new DateTime('+2 weeks');

while ($date < $maxDate) {
$year = $date->format('o');
Expand Down
17 changes: 12 additions & 5 deletions src/Mealz/UserBundle/DataFixtures/ORM/LoadUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function load(ObjectManager $manager): void
$this->addUser($user['username'], $user['password'], $user['firstName'], $user['lastName'], $user['roles']);
}

for ($i = 0; $i < 50; ++$i) {
for ($i = 0; $i < 15; ++$i) {
$this->createRandUser();
}

Expand All @@ -114,13 +114,19 @@ protected function addUser(
string $password,
string $firstName,
string $lastName,
array $roles
array $roles,
bool $isRandUser = false
): void {
$login = new Login();
$login->setUsername($username);

$hashedPassword = $this->passwordHasher->hashPassword($login, $password);
$login->setPassword($hashedPassword);
$environment = getenv('APP_ENV');
if (false === $isRandUser && 'prod' !== $environment && 'staging' !== $environment) {
$hashedPassword = $this->passwordHasher->hashPassword($login, $password);
$login->setPassword($hashedPassword);
} else {
$login->setPassword($password);
}

$profile = new Profile();
$profile->setUsername($username);
Expand Down Expand Up @@ -170,7 +176,8 @@ protected function createRandUser(): void
$randPass,
$randFirstName,
$randLastName,
['ROLE_USER']
['ROLE_USER'],
true
);
}
}
4 changes: 2 additions & 2 deletions tests/e2e/cypress/e2e/Costs.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ describe('Test Cost View', () => {

cy.get('input').first().clear();

cy.get('tr:visible').should('have.length', 57);
cy.get('tr:visible').should('have.length', 22);

cy.get('label').contains('Ausgeblendete Benutzer anzeigen').click();

cy.get('tr:visible').should('have.length', 58);
cy.get('tr:visible').should('have.length', 23);
});

it('should be able to settle an account', () => {
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const { initPlugin } = require("cypress-plugin-snapshots/plugin");
const { initPlugin } = require('cypress-plugin-snapshots/plugin');
const cypressSplit = require('cypress-split');

module.exports = (on, config) => {
initPlugin(on, config);
cypressSplit(on, config);
return config;
};
1 change: 1 addition & 0 deletions tests/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"cypress": "^12.12.0",
"cypress-keycloak": "^2.0.0",
"cypress-plugin-snapshots": "^1.4.4",
"cypress-split": "^1.24.0",
"typescript": "^5.0.4"
},
"dependencies": {}
Expand Down
Loading

0 comments on commit 2c1e8fe

Please sign in to comment.