Skip to content

Commit

Permalink
Fix: Let provisioning IP be assigned by CI
Browse files Browse the repository at this point in the history
Disable fixed IP for Vagrant provisioning and let GitHub CI assign one
dynamically.

Signed-off-by: Michal Polovka <[email protected]>
  • Loading branch information
miskopo committed Nov 24, 2023
1 parent 6dddb12 commit 4816d77
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/gating.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,29 @@ jobs:
restore-keys: |
${{ runner.os }}-vagrant-
- name: Cleanup running Vagrant boxes in case they are running
run: vagrant destroy --force

- name: Run vagrant up
run: vagrant up --no-provision

- name: Run vagrant provision
run: vagrant provision

- name: Put IPA Server's IP to /etc/hosts
run: sudo echo "192.168.56.101 server.ipa.demo" | sudo tee -a /etc/hosts
run: sudo echo "$(vagrant ssh -c "hostname -I") server.ipa.demo" | sudo tee -a /etc/hosts

- name: Save server's IP address to env
run: echo "SERVER_IP=$(vagrant ssh -c "hostname -I")" >> $GITHUB_ENV

- name: Print exported variable
run: echo "$SERVER_IP"

- name: Run Cypress tests
uses: cypress-io/github-action@v5
uses: cypress-io/github-action@v6
with:
browser: firefox
config: baseUrl=https://${{ env.SERVER_IP }}

- name: Upload cypress screenshots
uses: actions/upload-artifact@v2
Expand Down
7 changes: 2 additions & 5 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ Vagrant.configure("2") do |config|

# Needed by Cypress - optional if you edit your /etc/hosts
config.vm.network "forwarded_port", guest: 443, host: 443
config.vm.network "forwarded_port", guest: 80, host: 80
if ENV['GITHUB_CI']
config.vm.network "private_network",
:ip => "192.168.56.10",
:virtualbox__dhcp_enabled => false,
:virtualbox__network_address => '192.168.56.0/21',
:virtualbox__forward_mode => 'route'
end

Expand All @@ -39,7 +37,7 @@ Vagrant.configure("2") do |config|

# Add eth0 ip address to /etc/hosts
config.vm.provision "shell",
inline: "echo \"192.168.56.10 server.ipa.demo\" | tee -a /etc/hosts"
inline: "echo \"$(hostname -I) server.ipa.demo\" | tee -a /etc/hosts"

# Install ipa server
config.vm.provision "shell",
Expand Down Expand Up @@ -75,5 +73,4 @@ Vagrant.configure("2") do |config|
# Print instructions
config.vm.provision "shell",
inline: "echo \"Please append the line below to the /etc/hosts file on your machine:\n$(hostname -I)server.ipa.demo\""

end
1 change: 0 additions & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import createEsbuildPlugin from "@badeball/cypress-cucumber-preprocessor/esbuild
export default defineConfig({
e2e: {
specPattern: "**/*.feature",
baseUrl: "https://server.ipa.demo/",

async setupNodeEvents(
on: Cypress.PluginEvents,
Expand Down

0 comments on commit 4816d77

Please sign in to comment.