Skip to content

Commit

Permalink
Merge pull request #170 from poap-xyz/bugfix/failing-linux-tests
Browse files Browse the repository at this point in the history
Bugfix/failing linux tests
  • Loading branch information
actuallymentor authored Dec 18, 2023
2 parents d87ef40 + 6b7eafe commit 3a64e4e
Show file tree
Hide file tree
Showing 11 changed files with 565 additions and 507 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pr-status-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
steps.changed-files.outputs.any_changed == 'true'
run: |
echo -e "${{ secrets.DOTENV_DEVELOPMENT }}" > .env
echo -e "\nREACT_APP_useEmulator=true" >> .env
echo -e "\nVITE_useEmulator=true" >> .env
echo -e "${{ secrets.FUNCTIONS_DOTENV_DEVELOPMENT }}" > functions/.env.development
sed -i "s;%%cypress_cloud_service_url%%;${{ secrets.CYPRESS_CLOUD_SERVICE_URL }};g" currents.config.js
cd functions && npm run use:dev
Expand All @@ -87,7 +87,7 @@ jobs:
steps.changed-files.outputs.any_changed == 'true'
run: |
echo -e "${{ secrets.DOTENV_PRODUCTION }}" > .env
echo -e "\nREACT_APP_useEmulator=true" >> .env
echo -e "\nVITE_useEmulator=true" >> .env
echo -e "${{ secrets.FUNCTIONS_DOTENV_PRODUCTION }}" > functions/.env.production
sed -i "s;%%cypress_cloud_service_url%%;${{ secrets.CYPRESS_CLOUD_SERVICE_URL }};g" currents.config.js
cd functions && npm run use:prod
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"typescriptreact"
],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"editor.renderWhitespace": "all",
"editor.formatOnSave": true,
Expand Down
23 changes: 15 additions & 8 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ beforeEach( () => {

} )

// Stub google analytics requests
// Stub third party requests during testing
beforeEach( () => {

cy.intercept( 'https://unpkg.com/**/*', { middleware: true }, req => {
Expand All @@ -41,13 +41,7 @@ beforeEach( () => {
// Respond with a stubbed function
req.reply( ' () => console.log( "Stubbed Rive WASM CDN" )' )

} ).as( 'jsdelivr' )


} )

// Stub rive WASM requests
beforeEach( () => {
} ).as( 'jsdelivr_stub' )

cy.intercept( 'https://www.googletagmanager.com/**/*', { middleware: true }, req => {

Expand All @@ -62,6 +56,19 @@ beforeEach( () => {

} ).as( 'google_tag_stub' )

cy.intercept( 'https://*.matomo.cloud/**/*', { middleware: true }, req => {

// Disable request caching
req.on( 'before:response', ( res ) => {
// force all API responses to not be cached
res.headers[ 'cache-control' ] = 'no-store'
} )

// Respond with a stubbed function
req.reply( ' () => console.log( "Stubbed matomo" )' )

} ).as( 'matomo_stub' )


} )

Expand Down
2 changes: 1 addition & 1 deletion functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ exports.recalculate_available_codes = v2_oncall( recalculate_available_codes_adm

// On event registration, recalculate available codes
const { recalculate_available_codes } = require( './modules/codes' )
exports.recalculate_available_codes_on_event_registration = functions.runWith( { timeoutSeconds: 540, memory: '4GB' } ).firestore.document( `events/{eventId}` ).onCreate( ( { params } ) => recalculate_available_codes( params.eventId ) )
exports.recalculate_available_codes_on_event_registration = functions.runWith( { timeoutSeconds: 540, memory: '4GB' } ).firestore.document( `events/{eventId}` ).onCreate( ( snap, context ) => recalculate_available_codes( context.params.eventId ) )

// ///////////////////////////////
// Event data
Expand Down
3 changes: 3 additions & 0 deletions functions/scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Developer scripts

The scripts in this folder are convenience, scripts that are not used by the production system, and are purely for developer convenience.
42 changes: 42 additions & 0 deletions functions/scripts/lsof-visudo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#/bin/bash

# The script is designed to make lsof run without having to input a password for sudo

# Variables
visudo_folder=/etc/sudoers.d
visudo_file=${visudo_folder}/firebase_kill_emulators
tempfolder=/tmp
visudoconfig="
Cmnd_Alias LSOF = /usr/sbin/lsof -i
ALL ALL = NOPASSWD: LSOF
"

# Check if visudo file is correct, make it if not
function enable_visudo() {
echo "Checking visudo file format"
echo -e "$visudoconfig" >>$tempfolder/visudo.tmp
sudo visudo -c -f $tempfolder/visudo.tmp >/dev/null 2>&1
if [ "$?" -eq "0" ]; then
echo "visudo file format is correct"
if ! test -d "$visudo_folder"; then
echo "Creating folder $visudo_folder"
sudo mkdir -p "$visudo_folder"
fi
echo "Copying visudo file to $visudo_file"
sudo cp $tempfolder/visudo.tmp $visudo_file
rm $tempfolder/visudo.tmp
else
echo "visudo file format is incorrect, please check the file and try again"
rm $tempfolder/visudo.tmp
exit 1
fi
echo "Setting permissions on $visudo_file"
sudo chmod 440 $visudo_file
}

# Check if visudo file exists, make it if not
if ! test -f "$visudo_file"; then
enable_visudo
else
echo "visudo file exists, doing nothing"
fi
Loading

0 comments on commit 3a64e4e

Please sign in to comment.